Skip to content

Commit

Permalink
unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
go-to-k committed Mar 2, 2025
1 parent d80bd69 commit 45a276f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
9 changes: 1 addition & 8 deletions packages/aws-cdk-lib/aws-iam/lib/role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,7 @@ export class Role extends Resource implements IRole {
dummyValue: [
{
// eslint-disable-next-line @cdklabs/no-literal-partition
// Arn: 'arn:aws:iam::123456789012:role/DUMMY_ARN',
Arn: Stack.of(scope).formatArn({
region: '',
account: '123456789012',
service: 'iam',
resource: 'role',
resourceName: 'DUMMY_ARN',
}),
Arn: 'arn:aws:iam::123456789012:role/DUMMY_ARN',
},
],
}).value;
Expand Down
10 changes: 7 additions & 3 deletions packages/aws-cdk-lib/aws-iam/test/role.from-lookup.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as cxschema from '../../cloud-assembly-schema';
import { ContextProvider, Stack, Token } from '../../core';
import { CfnParameter, ContextProvider, Stack, Token } from '../../core';
import * as iam from '../lib';

/* eslint-disable */
Expand Down Expand Up @@ -46,10 +46,14 @@ describe('Role from lookup', () => {

test('throw error if role name is a token', () => {
// GIVEN
const tokenName = Token.asString('MyExistingRole');
const stack = new Stack(undefined, undefined, { env: { region: 'us-east-1', account: '123456789012' } });
const param = new CfnParameter(stack, 'MyParam', {
type: 'String',
default: 'MyExistingRole',
});

expect(() => iam.Role.fromLookup(stack, 'MyRole', {
roleName: tokenName,
roleName: param.valueAsString,
})).toThrow(/All arguments to look up a role must be concrete \(no Tokens\)/);
});
});
Expand Down

0 comments on commit 45a276f

Please sign in to comment.