Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: sub "_" with hash in resource logical ID in transformer v2 (#8600)
* fix: generate resource names with _ correctly * chore: clean up test code * test: update test after merge from master
- Loading branch information
1 parent
bf843b9
commit 6bb620b
Showing
3 changed files
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
packages/amplify-graphql-transformer-core/src/__tests__/transform-host.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { DefaultTransformHost } from '../transform-host'; | ||
import { GraphQLApi, TransformerAPIProps } from '../graphql-api'; | ||
import { App } from '@aws-cdk/core'; | ||
import { InlineTemplate } from '../cdk-compat/template-asset'; | ||
import { TransformerRootStack } from '../cdk-compat/root-stack'; | ||
|
||
describe('addResolver', () => { | ||
const app = new App(); | ||
const stack = new TransformerRootStack(app, 'test-root-stack'); | ||
const transformHost = new DefaultTransformHost({ api: new GraphQLApi(stack, 'testId', { name: 'testApiName' }) }); | ||
|
||
it('generates resolver name with hash for non-alphanumeric type names', () => { | ||
const cfnResolver = transformHost.addResolver( | ||
'test_type', | ||
'testField', | ||
new InlineTemplate('testTemplate'), | ||
new InlineTemplate('testTemplate'), | ||
undefined, | ||
undefined, | ||
['testPipelineConfig'], | ||
stack, | ||
); | ||
expect(cfnResolver.logicalId).toMatch('testtype4c79TestFieldResolver.LogicalID'); // have to use match instead of equals because the logicalId is a CDK token that has some non-deterministic stuff in it | ||
}); | ||
|
||
it('generates resolver name with hash for non-alphanumeric field names', () => { | ||
const cfnResolver = transformHost.addResolver( | ||
'testType', | ||
'test_field', | ||
new InlineTemplate('testTemplate'), | ||
new InlineTemplate('testTemplate'), | ||
undefined, | ||
undefined, | ||
['testPipelineConfig'], | ||
stack, | ||
); | ||
expect(cfnResolver.logicalId).toMatch('testTypeTestfield6a0fResolver.LogicalID'); // have to use match instead of equals because the logicalId is a CDK token that has some non-deterministic stuff in it | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters