Skip to content

Latest commit

 

History

History
92 lines (63 loc) · 2 KB

README.md

File metadata and controls

92 lines (63 loc) · 2 KB

CodePipeline mock

Basic mock of AWS CodePipeline API, which can be used with the AWS SDK, curl etc.

Usage

Start the mock server:

imposter up

Set the endpoint configuration property in the AWS SDK to http://localhost:8080, for example:

const client = new CodePipelineClient({
  endpoint: 'http://localhost:8080',
  // ...
});

For more details, see the Getting Started section.

Getting started

Prerequisites

Install Imposter CLI.

If using Homebrew:

brew tap gatehill/imposter
brew install imposter

Other installation options are available.

Start

Start the mock server:

imposter up

Using the mock

When using the AWS SDK, set the endpoint configuration property when creating the client:

const client = new CodePipelineClient({
  endpoint: 'http://localhost:8080',
  // ...
});

// list pipelines
const pipelines = await client.send(new ListPipelinesCommand({}));

// list pipeline executions
const executions = await client.send(new ListPipelineExecutionsCommand({
  pipelineName: 'my-pipeline',
}));

// get a pipeline execution
const execution = await client.send(new GetPipelineExecutionCommand({
  pipelineName: 'my-pipeline',
  pipelineExecutionId: 'my-execution-id',
}));

Using with imposter-js

The mock can also be started using the imposter-js library:

const { mocks } = require('@imposter-js/imposter');

// path to directory containing codepipeline-config.yaml
const configDir = __dirname;

// start a mock on a free port
const mock = await mocks.start(configDir);

// use the mock endpoint in your tests
const client = new CodePipelineClient({
    endpoint: mock.baseUrl(),
    // ...
});