Skip to content

Commit 6e2272d

Browse files
committed
add some unit tests
1 parent e182ef3 commit 6e2272d

File tree

1 file changed

+62
-2
lines changed

1 file changed

+62
-2
lines changed

test/ParameterStoreBuildWrapperPluginTest.groovy

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class ParameterStoreBuildWrapperPluginTest {
1515
public class Init {
1616
@After
1717
void resetPlugins() {
18+
TerraformValidateStage.resetPlugins()
1819
TerraformEnvironmentStage.reset()
1920
}
2021

@@ -25,6 +26,46 @@ class ParameterStoreBuildWrapperPluginTest {
2526
Collection actualPlugins = TerraformEnvironmentStage.getPlugins()
2627
assertThat(actualPlugins, hasItem(instanceOf(ParameterStoreBuildWrapperPlugin.class)))
2728
}
29+
30+
@Test
31+
void modifiesTerraformEnvironmentStageCommandWithGlobalParameter() {
32+
ParameterStoreBuildWrapperPlugin.withGlobalParameter('/somePath/').init()
33+
34+
Collection actualPlugins = TerraformEnvironmentStage.getPlugins()
35+
assertThat(actualPlugins, hasItem(instanceOf(ParameterStoreBuildWrapperPlugin.class)))
36+
}
37+
38+
@Test
39+
void modifiesTerraformEnvironmentStageCommandWithGlobalParameterAndOptions() {
40+
ParameterStoreBuildWrapperPlugin.withGlobalParameter('/somePath/', [someKey: true, anotherKey: 'someValue']).init()
41+
42+
Collection actualPlugins = TerraformEnvironmentStage.getPlugins()
43+
assertThat(actualPlugins, hasItem(instanceOf(ParameterStoreBuildWrapperPlugin.class)))
44+
}
45+
46+
@Test
47+
void modifiesTerraformValidateStageCommand() {
48+
ParameterStoreBuildWrapperPlugin.init()
49+
50+
Collection actualPlugins = TerraformValidateStage.getPlugins()
51+
assertThat(actualPlugins, hasItem(instanceOf(ParameterStoreBuildWrapperPlugin.class)))
52+
}
53+
54+
@Test
55+
void modifiesTerraformValidateStageCommandWithGlobalParameter() {
56+
ParameterStoreBuildWrapperPlugin.withGlobalParameter('/somePath/').init()
57+
58+
Collection actualPlugins = TerraformValidateStage.getPlugins()
59+
assertThat(actualPlugins, hasItem(instanceOf(ParameterStoreBuildWrapperPlugin.class)))
60+
}
61+
62+
@Test
63+
void modifiesTerraformValidateStageCommandWithGlobalParameterAndOptions() {
64+
ParameterStoreBuildWrapperPlugin.withGlobalParameter('/somePath/', [someKey: true, anotherKey: 'someValue']).init()
65+
66+
Collection actualPlugins = TerraformValidateStage.getPlugins()
67+
assertThat(actualPlugins, hasItem(instanceOf(ParameterStoreBuildWrapperPlugin.class)))
68+
}
2869
}
2970

3071
public class PathForEnvironment {
@@ -92,10 +133,29 @@ class ParameterStoreBuildWrapperPluginTest {
92133
}
93134

94135
@Test
95-
void addsGlobalParameter() {
136+
void addGlobalParameter() {
96137
def result = ParameterStoreBuildWrapperPlugin.withGlobalParameter('/path/', [])
97138

98-
assertEquals(ParameterStoreBuildWrapperPlugin.class, result)
139+
assertEquals([[path: '/path/']], result.globalParameterOptions)
140+
}
141+
142+
@Test
143+
void addGlobalParameterWithOptions() {
144+
def result = ParameterStoreBuildWrapperPlugin.withGlobalParameter('/path/', [recursive: true, basename: 'relative'])
145+
146+
assertEquals([[path: '/path/', recursive: true, basename: 'relative']], result.globalParameterOptions)
147+
}
148+
149+
@Test
150+
void addMulitpleGlobalParameters() {
151+
ArrayList expected = []
152+
def result = ParameterStoreBuildWrapperPlugin.withGlobalParameter('/path/', [])
153+
.withGlobalParameter('/path2/', [recursive: true])
154+
.withGlobalParameter('/path3/', [basename: 'something'])
155+
expected << [path:'/path/']
156+
expected << [path: '/path2/', recursive: true]
157+
expected << [path: '/path3/', basename: 'something']
158+
assertEquals(expected, result.globalParameterOptions)
99159
}
100160
}
101161
}

0 commit comments

Comments
 (0)