From 4858bea4e6db537931c25b2ac4e10fa81fc421b8 Mon Sep 17 00:00:00 2001 From: Jacob McCann Date: Tue, 31 Jul 2018 13:46:41 -0500 Subject: [PATCH] add tests for vars and var_files --- plugin_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/plugin_test.go b/plugin_test.go index 29f206d..7cdd349 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -87,6 +87,16 @@ func TestPlugin(t *testing.T) { args{config: Config{Targets: []string{"target1", "target2"}}}, exec.Command("terraform", "destroy", "-target=target1", "-target=target2", "-force"), }, + { + "with vars", + args{config: Config{Vars: map[string]string{"username": "someuser", "password": "1pass"}}}, + exec.Command("terraform", "destroy", "-var", "username=someuser", "-var", "password=1pass", "-force"), + }, + { + "with var-files", + args{config: Config{VarFiles: []string{"common.tfvars", "prod.tfvars"}}}, + exec.Command("terraform", "destroy", "-var-file=common.tfvars", "-var-file=prod.tfvars", "-force"), + }, } for _, tt := range tests { @@ -119,6 +129,18 @@ func TestPlugin(t *testing.T) { true, exec.Command("terraform", "plan", "-destroy"), }, + { + "with vars", + args{config: Config{Vars: map[string]string{"username": "someuser", "password": "1pass"}}}, + false, + exec.Command("terraform", "plan", "-out=plan.tfout", "-var", "username=someuser", "-var", "password=1pass"), + }, + { + "with var-files", + args{config: Config{VarFiles: []string{"common.tfvars", "prod.tfvars"}}}, + false, + exec.Command("terraform", "plan", "-out=plan.tfout", "-var-file=common.tfvars", "-var-file=prod.tfvars"), + }, } for _, tt := range tests {