From bc0f9e28d70f83b3d014cd2f525f570fe5107153 Mon Sep 17 00:00:00 2001 From: Ezbon Jacob Date: Mon, 21 Sep 2020 17:25:13 -0400 Subject: [PATCH] add some unit tests --- ...arameterStoreBuildWrapperPluginTest.groovy | 48 ++++++++++++++++++- 1 file changed, 46 insertions(+), 2 deletions(-) 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) } } }