Skip to content

Commit bc0f9e2

Browse files
committed
add some unit tests
1 parent e182ef3 commit bc0f9e2

File tree

1 file changed

+46
-2
lines changed

1 file changed

+46
-2
lines changed

test/ParameterStoreBuildWrapperPluginTest.groovy

Lines changed: 46 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,30 @@ class ParameterStoreBuildWrapperPluginTest {
2526
Collection actualPlugins = TerraformEnvironmentStage.getPlugins()
2627
assertThat(actualPlugins, hasItem(instanceOf(ParameterStoreBuildWrapperPlugin.class)))
2728
}
29+
30+
@Test
31+
void modifiesTerraformValidateStageCommand() {
32+
ParameterStoreBuildWrapperPlugin.init()
33+
34+
Collection actualPlugins = TerraformValidateStage.getPlugins()
35+
assertThat(actualPlugins, hasItem(instanceOf(ParameterStoreBuildWrapperPlugin.class)))
36+
}
37+
38+
@Test
39+
void modifiesTerraformEnvironmentStageCommandWithGlobalParameter() {
40+
ParameterStoreBuildWrapperPlugin.withGlobalParameter('/somePath/').init()
41+
42+
Collection actualPlugins = TerraformEnvironmentStage.getPlugins()
43+
assertThat(actualPlugins, hasItem(instanceOf(ParameterStoreBuildWrapperPlugin.class)))
44+
}
45+
46+
@Test
47+
void modifiesTerraformValidateStageCommandWithGlobalParameter() {
48+
ParameterStoreBuildWrapperPlugin.withGlobalParameter('/somePath/').init()
49+
50+
Collection actualPlugins = TerraformValidateStage.getPlugins()
51+
assertThat(actualPlugins, hasItem(instanceOf(ParameterStoreBuildWrapperPlugin.class)))
52+
}
2853
}
2954

3055
public class PathForEnvironment {
@@ -92,10 +117,29 @@ class ParameterStoreBuildWrapperPluginTest {
92117
}
93118

94119
@Test
95-
void addsGlobalParameter() {
120+
void addGlobalParameter() {
96121
def result = ParameterStoreBuildWrapperPlugin.withGlobalParameter('/path/', [])
97122

98-
assertEquals(ParameterStoreBuildWrapperPlugin.class, result)
123+
assertEquals([[path: '/path/']], result.globalParameterOptions)
124+
}
125+
126+
@Test
127+
void addGlobalParameterWithOptions() {
128+
def result = ParameterStoreBuildWrapperPlugin.withGlobalParameter('/path/', [recursive: true, basename: 'relative'])
129+
130+
assertEquals([[path: '/path/', recursive: true, basename: 'relative']], result.globalParameterOptions)
131+
}
132+
133+
@Test
134+
void addMulitpleGlobalParameters() {
135+
ArrayList expected = []
136+
def result = ParameterStoreBuildWrapperPlugin.withGlobalParameter('/path/', [])
137+
.withGlobalParameter('/path2/', [recursive: true])
138+
.withGlobalParameter('/path3/', [basename: 'something'])
139+
expected << [path:'/path/']
140+
expected << [path: '/path2/', recursive: true]
141+
expected << [path: '/path3/', basename: 'something']
142+
assertEquals(expected, result.globalParameterOptions)
99143
}
100144
}
101145
}

0 commit comments

Comments
 (0)