Skip to content

Commit

Permalink
rename deployAssert to assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
corymhall committed May 23, 2022
1 parent f0b6afd commit 51b1907
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ const integ = new IntegTest(app, 'Destinations', {
testCases: [stack],
});

integ.deployAssert.invokeFunction({
integ.assertions.invokeFunction({
functionName: stack.fn.functionName,
invocationType: InvocationType.EVENT,
payload: JSON.stringify({ status: 'OK' }),
});

const message = integ.deployAssert.awsApiCall('SQS', 'receiveMessage', {
const message = integ.assertions.awsApiCall('SQS', 'receiveMessage', {
QueueUrl: stack.queue.queueUrl,
WaitTimeSeconds: 20,
});
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-lambda/test/integ.bundling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const integ = new IntegTest(app, 'Bundling', {
stackUpdateWorkflow: false,
});

const invoke = integ.deployAssert.invokeFunction({
const invoke = integ.assertions.invokeFunction({
functionName: stack.functionName,
});
invoke.expect(ExpectedResult.objectLike({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ const testCase = new IntegTest(app, 'PutEvents', {
});

// Start an execution
const start = testCase.deployAssert.awsApiCall('StepFunctions', 'startExecution', {
const start = testCase.assertions.awsApiCall('StepFunctions', 'startExecution', {
stateMachineArn: sm.stateMachineArn,
});

// describe the results of the execution
const describe = testCase.deployAssert.awsApiCall('StepFunctions', 'describeExecution', {
const describe = testCase.assertions.awsApiCall('StepFunctions', 'describeExecution', {
executionArn: start.getAttString('executionArn'),
});

Expand Down
16 changes: 8 additions & 8 deletions packages/@aws-cdk/integ-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ declare const app: App;
declare const stack: Stack;

const integ = new IntegTest(app, 'Integ', { testCases: [stack] });
integ.deployAssert.awsApiCall('S3', 'getObject');
integ.assertions.awsApiCall('S3', 'getObject');
```

- Part of a normal CDK deployment
Expand Down Expand Up @@ -220,7 +220,7 @@ declare const stack: Stack;
declare const app: App;

const integ = new IntegTest(app, 'Integ', { testCases: [stack] });
integ.deployAssert.expect(
integ.assertions.expect(
'CustomAssertion',
ExpectedResult.objectLike({ foo: 'bar' }),
ActualResult.fromCustomResource(myCustomResource, 'data'),
Expand Down Expand Up @@ -259,7 +259,7 @@ declare const stack: Stack;
const integ = new IntegTest(app, 'Integ', {
testCases: [stack],
});
integ.deployAssert.awsApiCall('SQS', 'receiveMessage', {
integ.assertions.awsApiCall('SQS', 'receiveMessage', {
QueueUrl: 'url',
});
```
Expand All @@ -282,13 +282,13 @@ const integ = new IntegTest(app, 'Integ', {
testCases: [stack],
});

integ.deployAssert.invokeFunction({
integ.assertions.invokeFunction({
functionName: fn.functionName,
invocationType: InvocationType.EVENT,
payload: JSON.stringify({ status: 'OK' }),
});

const message = integ.deployAssert.awsApiCall('SQS', 'receiveMessage', {
const message = integ.assertions.awsApiCall('SQS', 'receiveMessage', {
QueueUrl: queue.queueUrl,
WaitTimeSeconds: 20,
});
Expand Down Expand Up @@ -344,7 +344,7 @@ const integ = new IntegTest(app, 'IntegTest', {
testCases: [stack],
});

const invoke = integ.deployAssert.invokeFunction({
const invoke = integ.assertions.invokeFunction({
functionName: lambdaFunction.functionName,
});
invoke.expect(ExpectedResult.objectLike({
Expand All @@ -367,12 +367,12 @@ const testCase = new IntegTest(app, 'IntegTest', {
});

// Start an execution
const start = testCase.deployAssert.awsApiCall('StepFunctions', 'startExecution', {
const start = testCase.assertions.awsApiCall('StepFunctions', 'startExecution', {
stateMachineArn: sm.stateMachineArn,
});

// describe the results of the execution
const describe = testCase.deployAssert.awsApiCall('StepFunctions', 'describeExecution', {
const describe = testCase.assertions.awsApiCall('StepFunctions', 'describeExecution', {
executionArn: start.getAttString('executionArn'),
});

Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/integ-tests/lib/assertions/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export interface IAwsApiCall extends IConstruct {
*
* @example
* declare const integ: IntegTest;
* const invoke = integ.deployAssert.invokeFunction({
* const invoke = integ.assertions.invokeFunction({
* functionName: 'my-func',
* });
* invoke.expect(ExpectedResult.objectLike({ Payload: 'OK' }));
Expand Down Expand Up @@ -75,7 +75,7 @@ export interface IAwsApiCall extends IConstruct {
*
*
* declare const integ: IntegTest;
* const message = integ.deployAssert.awsApiCall('SQS', 'receiveMessage');
* const message = integ.assertions.awsApiCall('SQS', 'receiveMessage');
*
* message.assertAtPath('Messages.0.Body', ExpectedResult.stringLikeRegexp('hello'));
*/
Expand Down
8 changes: 4 additions & 4 deletions packages/@aws-cdk/integ-tests/lib/assertions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export interface IDeployAssert {
* @example
* declare const app: App;
* declare const integ: IntegTest;
* integ.deployAssert.awsApiCall('SQS', 'sendMessage', {
* integ.assertions.awsApiCall('SQS', 'sendMessage', {
* QueueUrl: 'url',
* MessageBody: 'hello',
* });
* const message = integ.deployAssert.awsApiCall('SQS', 'receiveMessage', {
* const message = integ.assertions.awsApiCall('SQS', 'receiveMessage', {
* QueueUrl: 'url',
* });
* message.expect(ExpectedResult.objectLike({
Expand All @@ -34,7 +34,7 @@ export interface IDeployAssert {
* @example
* declare const app: App;
* declare const integ: IntegTest;
* const invoke = integ.deployAssert.invokeFunction({
* const invoke = integ.assertions.invokeFunction({
* functionName: 'my-function',
* });
* invoke.expect(ExpectedResult.objectLike({
Expand All @@ -50,7 +50,7 @@ export interface IDeployAssert {
* @example
* declare const integ: IntegTest;
* declare const apiCall: AwsApiCall;
* integ.deployAssert.expect(
* integ.assertions.expect(
* 'invoke',
* ExpectedResult.objectLike({ Payload: 'OK' }),
* ActualResult.fromAwsApiCall(apiCall, 'Body'),
Expand Down
12 changes: 6 additions & 6 deletions packages/@aws-cdk/integ-tests/lib/test-case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ export class IntegTestCase extends CoreConstruct {
/**
* Make assertions on resources in this test case
*/
public readonly deployAssert: IDeployAssert;
public readonly assertions: IDeployAssert;

private readonly _assert: DeployAssert;

constructor(scope: Construct, id: string, private readonly props: IntegTestCaseProps) {
super(scope, id);

this._assert = new DeployAssert(this);
this.deployAssert = this._assert;
this.assertions = this._assert;
}

/**
Expand Down Expand Up @@ -87,7 +87,7 @@ export class IntegTestCaseStack extends Stack {
/**
* Make assertions on resources in this test case
*/
public readonly deployAssert: IDeployAssert;
public readonly assertions: IDeployAssert;

/**
* The underlying IntegTestCase that is created
Expand All @@ -101,7 +101,7 @@ export class IntegTestCaseStack extends Stack {
Object.defineProperty(this, TEST_CASE_STACK_SYMBOL, { value: true });

// TODO: should we only have a single DeployAssert per test?
this.deployAssert = new DeployAssert(this);
this.assertions = new DeployAssert(this);
this._testCase = new IntegTestCase(this, `${id}TestCase`, {
...props,
stacks: [this],
Expand All @@ -128,7 +128,7 @@ export class IntegTest extends CoreConstruct {
/**
* Make assertions on resources in this test case
*/
public readonly deployAssert: IDeployAssert;
public readonly assertions: IDeployAssert;
private readonly testCases: IntegTestCase[];
constructor(scope: Construct, id: string, props: IntegTestProps) {
super(scope, id);
Expand All @@ -142,7 +142,7 @@ export class IntegTest extends CoreConstruct {
cdkCommandOptions: props.cdkCommandOptions,
stackUpdateWorkflow: props.stackUpdateWorkflow,
});
this.deployAssert = defaultTestCase.deployAssert;
this.assertions = defaultTestCase.assertions;

this.testCases = [
defaultTestCase,
Expand Down

0 comments on commit 51b1907

Please sign in to comment.