Skip to content

Commit

Permalink
add some unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
codezninja committed Sep 21, 2020
1 parent e182ef3 commit bc0f9e2
Showing 1 changed file with 46 additions and 2 deletions.
48 changes: 46 additions & 2 deletions test/ParameterStoreBuildWrapperPluginTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ParameterStoreBuildWrapperPluginTest {
public class Init {
@After
void resetPlugins() {
TerraformValidateStage.resetPlugins()
TerraformEnvironmentStage.reset()
}

Expand All @@ -25,6 +26,30 @@ class ParameterStoreBuildWrapperPluginTest {
Collection actualPlugins = TerraformEnvironmentStage.getPlugins()
assertThat(actualPlugins, hasItem(instanceOf(ParameterStoreBuildWrapperPlugin.class)))
}

@Test
void modifiesTerraformValidateStageCommand() {
ParameterStoreBuildWrapperPlugin.init()

Collection actualPlugins = TerraformValidateStage.getPlugins()
assertThat(actualPlugins, hasItem(instanceOf(ParameterStoreBuildWrapperPlugin.class)))
}

@Test
void modifiesTerraformEnvironmentStageCommandWithGlobalParameter() {
ParameterStoreBuildWrapperPlugin.withGlobalParameter('/somePath/').init()

Collection actualPlugins = TerraformEnvironmentStage.getPlugins()
assertThat(actualPlugins, hasItem(instanceOf(ParameterStoreBuildWrapperPlugin.class)))
}

@Test
void modifiesTerraformValidateStageCommandWithGlobalParameter() {
ParameterStoreBuildWrapperPlugin.withGlobalParameter('/somePath/').init()

Collection actualPlugins = TerraformValidateStage.getPlugins()
assertThat(actualPlugins, hasItem(instanceOf(ParameterStoreBuildWrapperPlugin.class)))
}
}

public class PathForEnvironment {
Expand Down Expand Up @@ -92,10 +117,29 @@ class ParameterStoreBuildWrapperPluginTest {
}

@Test
void addsGlobalParameter() {
void addGlobalParameter() {
def result = ParameterStoreBuildWrapperPlugin.withGlobalParameter('/path/', [])

assertEquals(ParameterStoreBuildWrapperPlugin.class, result)
assertEquals([[path: '/path/']], result.globalParameterOptions)
}

@Test
void addGlobalParameterWithOptions() {
def result = ParameterStoreBuildWrapperPlugin.withGlobalParameter('/path/', [recursive: true, basename: 'relative'])

assertEquals([[path: '/path/', recursive: true, basename: 'relative']], result.globalParameterOptions)
}

@Test
void addMulitpleGlobalParameters() {
ArrayList expected = []
def result = ParameterStoreBuildWrapperPlugin.withGlobalParameter('/path/', [])
.withGlobalParameter('/path2/', [recursive: true])
.withGlobalParameter('/path3/', [basename: 'something'])
expected << [path:'/path/']
expected << [path: '/path2/', recursive: true]
expected << [path: '/path3/', basename: 'something']
assertEquals(expected, result.globalParameterOptions)
}
}
}
Expand Down

0 comments on commit bc0f9e2

Please sign in to comment.