@@ -2,7 +2,7 @@ import { expect, haveResource, haveResourceLike } from '@aws-cdk/assert';
2
2
import iam = require( '@aws-cdk/aws-iam' ) ;
3
3
import { ServicePrincipal } from '@aws-cdk/aws-iam' ;
4
4
import cdk = require( '@aws-cdk/core' ) ;
5
- import { Stack } from '@aws-cdk/core' ;
5
+ import { CfnResource , Stack } from '@aws-cdk/core' ;
6
6
import { Test } from 'nodeunit' ;
7
7
import { EventField , IRule , IRuleTarget , RuleTargetConfig , RuleTargetInput , Schedule } from '../lib' ;
8
8
import { Rule } from '../lib/rule' ;
@@ -31,6 +31,26 @@ export = {
31
31
test . done ( ) ;
32
32
} ,
33
33
34
+ 'can get rule name' ( test : Test ) {
35
+ const stack = new cdk . Stack ( ) ;
36
+ const rule = new Rule ( stack , 'MyRule' , {
37
+ schedule : Schedule . rate ( cdk . Duration . minutes ( 10 ) ) ,
38
+ } ) ;
39
+
40
+ new CfnResource ( stack , 'Res' , {
41
+ type : 'Test::Resource' ,
42
+ properties : {
43
+ RuleName : rule . ruleName
44
+ }
45
+ } ) ;
46
+
47
+ expect ( stack ) . to ( haveResource ( 'Test::Resource' , {
48
+ RuleName : { Ref : 'MyRuleA44AB831' }
49
+ } ) ) ;
50
+
51
+ test . done ( ) ;
52
+ } ,
53
+
34
54
'rule with physical name' ( test : Test ) {
35
55
// GIVEN
36
56
const stack = new cdk . Stack ( ) ;
@@ -366,10 +386,11 @@ export = {
366
386
const stack = new Stack ( ) ;
367
387
368
388
// WHEN
369
- const importedRule = Rule . fromEventRuleArn ( stack , 'ImportedRule' , 'arn:of: rule' ) ;
389
+ const importedRule = Rule . fromEventRuleArn ( stack , 'ImportedRule' , 'arn:aws:events:us-east-2:123456789012: rule/example ' ) ;
370
390
371
391
// THEN
372
- test . deepEqual ( importedRule . ruleArn , 'arn:of:rule' ) ;
392
+ test . deepEqual ( importedRule . ruleArn , 'arn:aws:events:us-east-2:123456789012:rule/example' ) ;
393
+ test . deepEqual ( importedRule . ruleName , 'example' ) ;
373
394
test . done ( ) ;
374
395
} ,
375
396
0 commit comments