Skip to content

Commit 0d10b1b

Browse files
committed
chore: update test specs
1 parent 24a8722 commit 0d10b1b

File tree

5 files changed

+877
-157
lines changed

5 files changed

+877
-157
lines changed

spec/cache-cluster_spec.rb

Lines changed: 169 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,183 @@
11
require 'yaml'
22

3-
describe 'should be valid' do
3+
describe 'compiled component redis' do
44

55
context 'cftest' do
66
it 'compiles test' do
77
expect(system("cfhighlander cftest #{@validate} --tests tests/cache-cluster.test.yaml")).to be_truthy
8-
end
8+
end
99
end
10-
10+
1111
let(:template) { YAML.load_file("#{File.dirname(__FILE__)}/../out/tests/cache-cluster/redis.compiled.yaml") }
12+
13+
context "Resource" do
14+
15+
16+
context "SecurityGroupRedis" do
17+
let(:resource) { template["Resources"]["SecurityGroupRedis"] }
18+
19+
it "is of type AWS::EC2::SecurityGroup" do
20+
expect(resource["Type"]).to eq("AWS::EC2::SecurityGroup")
21+
end
22+
23+
it "to have property VpcId" do
24+
expect(resource["Properties"]["VpcId"]).to eq({"Ref"=>"VPCId"})
25+
end
26+
27+
it "to have property GroupDescription" do
28+
expect(resource["Properties"]["GroupDescription"]).to eq({"Fn::Sub"=>"${EnvironmentName}-redis"})
29+
end
30+
31+
it "to have property SecurityGroupEgress" do
32+
expect(resource["Properties"]["SecurityGroupEgress"]).to eq([{"CidrIp"=>"0.0.0.0/0", "Description"=>"Outbound for all ports", "IpProtocol"=>"-1"}])
33+
end
34+
35+
it "to have property Tags" do
36+
expect(resource["Properties"]["Tags"]).to eq([{"Key"=>"Name", "Value"=>{"Fn::Sub"=>"${EnvironmentName}-redis"}}, {"Key"=>"Environment", "Value"=>{"Ref"=>"EnvironmentName"}}, {"Key"=>"EnvironmentType", "Value"=>{"Ref"=>"EnvironmentType"}}])
37+
end
38+
39+
end
40+
41+
context "SubnetGroupRedis" do
42+
let(:resource) { template["Resources"]["SubnetGroupRedis"] }
43+
44+
it "is of type AWS::ElastiCache::SubnetGroup" do
45+
expect(resource["Type"]).to eq("AWS::ElastiCache::SubnetGroup")
46+
end
47+
48+
it "to have property Description" do
49+
expect(resource["Properties"]["Description"]).to eq({"Fn::Sub"=>"${EnvironmentName}-redis"})
50+
end
51+
52+
it "to have property SubnetIds" do
53+
expect(resource["Properties"]["SubnetIds"]).to eq({"Ref"=>"Subnets"})
54+
end
55+
56+
end
57+
58+
context "ParameterGroupRedis" do
59+
let(:resource) { template["Resources"]["ParameterGroupRedis"] }
1260

13-
context 'Resource ReplicationGroupRedis' do
14-
15-
let(:properties) { template["Resources"]["ReplicationGroupRedis"]["Properties"] }
16-
17-
it 'has property' do
18-
expect(properties).to eq({
19-
"AtRestEncryptionEnabled" => true,
20-
"AutoMinorVersionUpgrade" => true,
21-
"AutomaticFailoverEnabled" => true,
22-
"CacheNodeType" => {"Ref"=>"InstanceType"},
23-
"CacheParameterGroupName" => {"Ref"=>"ParameterGroupRedis"},
24-
"CacheSubnetGroupName" => {"Ref"=>"SubnetGroupRedis"},
25-
"DataTieringEnabled" => {"Fn::If"=>["DataTieringEnabled", {"Ref"=>"DataTieringEnabled"}, {"Ref"=>"AWS::NoValue"}]},
26-
"Engine" => "redis",
27-
"NumCacheClusters" => {"Ref"=>"NumCacheClusters"},
28-
"ReplicationGroupDescription" => {"Fn::Sub"=>"${EnvironmentName}-redis"},
29-
"SecurityGroupIds" => [{"Ref"=>"SecurityGroupRedis"}],
30-
"SnapshotArns" => {"Fn::If" => ["NoSnapshotArnsEnabled", {"Ref" => "AWS::NoValue"}, {"Fn::Split" => [",", {"Ref" => "SnapshotArns"}]}]},
31-
"SnapshotName" => {"Fn::If" => ["NoSnapshotNamEnabled", {"Ref" => "AWS::NoValue"}, {"Ref" => "SnapshotName"}]},
32-
"SnapshotRetentionLimit" => {"Ref"=>"SnapshotRetentionLimit"},
33-
"Tags" => [
34-
{"Key"=>"Name", "Value"=>{"Fn::Sub"=>"${EnvironmentName}-redis"}},
35-
{"Key"=>"Environment", "Value"=>{"Ref"=>"EnvironmentName"}},
36-
{"Key"=>"EnvironmentType", "Value"=>{"Ref"=>"EnvironmentType"}}
37-
],
38-
"TransitEncryptionEnabled" => true,
39-
})
61+
it "is of type AWS::ElastiCache::ParameterGroup" do
62+
expect(resource["Type"]).to eq("AWS::ElastiCache::ParameterGroup")
63+
end
64+
65+
it "to have property CacheParameterGroupFamily" do
66+
expect(resource["Properties"]["CacheParameterGroupFamily"]).to eq("redis6.x")
67+
end
68+
69+
it "to have property Description" do
70+
expect(resource["Properties"]["Description"]).to eq({"Fn::Sub"=>"${EnvironmentName}-redis"})
71+
end
72+
73+
it "to have property Properties" do
74+
expect(resource["Properties"]["Properties"]).to eq({"cluster-enabled"=>"yes"})
75+
end
76+
4077
end
78+
79+
context "ReplicationGroupRedis" do
80+
let(:resource) { template["Resources"]["ReplicationGroupRedis"] }
4181

82+
it "is of type AWS::ElastiCache::ReplicationGroup" do
83+
expect(resource["Type"]).to eq("AWS::ElastiCache::ReplicationGroup")
84+
end
85+
86+
it "to have property ReplicationGroupDescription" do
87+
expect(resource["Properties"]["ReplicationGroupDescription"]).to eq({"Fn::Sub"=>"${EnvironmentName}-redis"})
88+
end
89+
90+
it "to have property Engine" do
91+
expect(resource["Properties"]["Engine"]).to eq("redis")
92+
end
93+
94+
it "to have property TransitEncryptionEnabled" do
95+
expect(resource["Properties"]["TransitEncryptionEnabled"]).to eq(true)
96+
end
97+
98+
it "to have property AtRestEncryptionEnabled" do
99+
expect(resource["Properties"]["AtRestEncryptionEnabled"]).to eq(true)
100+
end
101+
102+
it "to have property AutoMinorVersionUpgrade" do
103+
expect(resource["Properties"]["AutoMinorVersionUpgrade"]).to eq(true)
104+
end
105+
106+
it "to have property AutomaticFailoverEnabled" do
107+
expect(resource["Properties"]["AutomaticFailoverEnabled"]).to eq(true)
108+
end
109+
110+
it "to have property DataTieringEnabled" do
111+
expect(resource["Properties"]["DataTieringEnabled"]).to eq({"Fn::If"=>["DataTieringEnabled", {"Ref"=>"DataTieringEnabled"}, {"Ref"=>"AWS::NoValue"}]})
112+
end
113+
114+
it "to have property CacheNodeType" do
115+
expect(resource["Properties"]["CacheNodeType"]).to eq({"Ref"=>"InstanceType"})
116+
end
117+
118+
it "to have property CacheParameterGroupName" do
119+
expect(resource["Properties"]["CacheParameterGroupName"]).to eq({"Ref"=>"ParameterGroupRedis"})
120+
end
121+
122+
it "to have property CacheSubnetGroupName" do
123+
expect(resource["Properties"]["CacheSubnetGroupName"]).to eq({"Ref"=>"SubnetGroupRedis"})
124+
end
125+
126+
it "to have property SecurityGroupIds" do
127+
expect(resource["Properties"]["SecurityGroupIds"]).to eq([{"Ref"=>"SecurityGroupRedis"}])
128+
end
129+
130+
it "to have property NumCacheClusters" do
131+
expect(resource["Properties"]["NumCacheClusters"]).to eq({"Ref"=>"NumCacheClusters"})
132+
end
133+
134+
it "to have property SnapshotName" do
135+
expect(resource["Properties"]["SnapshotName"]).to eq({"Fn::If"=>["NoSnapshotNamEnabled", {"Ref"=>"AWS::NoValue"}, {"Ref"=>"SnapshotName"}]})
136+
end
137+
138+
it "to have property SnapshotArns" do
139+
expect(resource["Properties"]["SnapshotArns"]).to eq({"Fn::If"=>["NoSnapshotArnsEnabled", {"Ref"=>"AWS::NoValue"}, {"Fn::Split"=>[",", {"Ref"=>"SnapshotArns"}]}]})
140+
end
141+
142+
it "to have property SnapshotRetentionLimit" do
143+
expect(resource["Properties"]["SnapshotRetentionLimit"]).to eq({"Ref"=>"SnapshotRetentionLimit"})
144+
end
145+
146+
it "to have property Tags" do
147+
expect(resource["Properties"]["Tags"]).to eq([{"Key"=>"Name", "Value"=>{"Fn::Sub"=>"${EnvironmentName}-redis"}}, {"Key"=>"Environment", "Value"=>{"Ref"=>"EnvironmentName"}}, {"Key"=>"EnvironmentType", "Value"=>{"Ref"=>"EnvironmentType"}}])
148+
end
149+
150+
end
151+
152+
context "HostRecordRedis" do
153+
let(:resource) { template["Resources"]["HostRecordRedis"] }
154+
155+
it "is of type AWS::Route53::RecordSet" do
156+
expect(resource["Type"]).to eq("AWS::Route53::RecordSet")
157+
end
158+
159+
it "to have property HostedZoneName" do
160+
expect(resource["Properties"]["HostedZoneName"]).to eq({"Fn::Sub"=>"${EnvironmentName}.${DnsDomain}."})
161+
end
162+
163+
it "to have property Name" do
164+
expect(resource["Properties"]["Name"]).to eq({"Fn::Sub"=>"redis.${EnvironmentName}.${DnsDomain}."})
165+
end
166+
167+
it "to have property Type" do
168+
expect(resource["Properties"]["Type"]).to eq("CNAME")
169+
end
170+
171+
it "to have property TTL" do
172+
expect(resource["Properties"]["TTL"]).to eq("60")
173+
end
174+
175+
it "to have property ResourceRecords" do
176+
expect(resource["Properties"]["ResourceRecords"]).to eq([{"Fn::GetAtt"=>["ReplicationGroupRedis", "ConfigurationEndPoint.Address"]}])
177+
end
178+
179+
end
180+
42181
end
43182

44183
end

0 commit comments

Comments
 (0)