diff --git a/test/ParameterStoreBuildWrapperPluginTest.groovy b/test/ParameterStoreBuildWrapperPluginTest.groovy index 59d5c084..804e7223 100644 --- a/test/ParameterStoreBuildWrapperPluginTest.groovy +++ b/test/ParameterStoreBuildWrapperPluginTest.groovy @@ -15,6 +15,7 @@ class ParameterStoreBuildWrapperPluginTest { public class Init { @After void resetPlugins() { + TerraformValidateStage.resetPlugins() TerraformEnvironmentStage.reset() } @@ -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 { @@ -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) } } }