From 5b6b03d2466b689c76c29b667cc4318a3e248047 Mon Sep 17 00:00:00 2001 From: Mike Ball Date: Thu, 24 Aug 2023 10:49:11 -0400 Subject: [PATCH] improve replace-provider's unit tests This seeks to add additional unit tests surrounding scenarios where... * `terraform version` succeeds, but returns an unsupported version * `terraform version` exits nonzero --- tfexec/terraform_state_replace_provider_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tfexec/terraform_state_replace_provider_test.go b/tfexec/terraform_state_replace_provider_test.go index e881935..6c51577 100644 --- a/tfexec/terraform_state_replace_provider_test.go +++ b/tfexec/terraform_state_replace_provider_test.go @@ -98,6 +98,23 @@ func TestTerraformCLIStateReplaceProvider(t *testing.T) { argsRe: regexp.MustCompile(`^terraform version$`), runFunc: versionRunFunc, stdout: "Terraform v0.12.99\n", + exitCode: 0, + }, + }, + state: nil, + source: "registry.terraform.io/-/null", + destination: "registry.terraform.io/hashicorp/null", + updatedState: nil, + ok: false, + }, + { + desc: "when version check fails", + mockCommands: []*mockCommand{ + { + args: []string{"terraform", "version"}, + argsRe: regexp.MustCompile(`^terraform version$`), + runFunc: versionRunFunc, + stdout: "Terraform v1.4.7\n", exitCode: 1, }, },