Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integ-tests: broken assertion caused by getAttX calls #30477

Open
nmussy opened this issue Jun 7, 2024 · 0 comments
Open

integ-tests: broken assertion caused by getAttX calls #30477

nmussy opened this issue Jun 7, 2024 · 0 comments
Labels
@aws-cdk/integ-tests bug This issue is a bug. effort/medium Medium work item – several days of effort p2

Comments

@nmussy
Copy link
Contributor

nmussy commented Jun 7, 2024

Describe the bug

Running getAtt or getAttString on a SDK integration will cause the flattenResults property to be set, allowing users to retrieve JSONPath-ish property values. However, this also causes assertions for that integration to fail

Expected Behavior

Given that flattenResults is not exposed to the user, they would expect their object/path assertions to work regardless of getAttX calls.

Current Behavior

actual is undefined:

Reproduction Steps

import * as cdk from 'aws-cdk-lib';
import { ExpectedResult, IntegTest } from '../../../lib';

const app = new cdk.App();

const stack = new cdk.Stack(app, 'foo');

const integ = new IntegTest(app, 'Integ', {
  testCases: [stack],
});

const models = integ.assertions.awsApiCall('Bedrock', 'GetFoundationModel', {
  modelIdentifier: 'amazon.titan-embed-text-v1',
});

models.expect(ExpectedResult.objectLike({
  modelDetails: { modelId: 'amazon.titan-embed-text-v1' },
}));

// Enabling this line will cause the assertion to fail
// eslint-disable-next-line no-console
// console.log(models.getAttString('modelDetails.modelName'));

Output:

Expected type object but received undefined

Possible Solution

I'm assuming the flattened object is not being sent/parsed properly. Reversion the flattening process in AssertionHandler would be satisfactory

Additional Information/Context

No response

CDK CLI Version

2.144.0

Framework Version

No response

Node.js Version

v20.11.1

OS

macOS 14.4.1

Language

TypeScript

Language Version

No response

Other information

I discovered this issue while attempting to write an integration test for #30361, which implements flattenResults for HTTP assertions

@nmussy nmussy added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 7, 2024
@pahud pahud added p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/integ-tests bug This issue is a bug. effort/medium Medium work item – several days of effort p2
Projects
None yet
Development

No branches or pull requests

2 participants