From ef4fee5acbf65b9dd4c57f79b32df4bc9be4ad47 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Wed, 21 Oct 2020 18:24:09 -0400 Subject: [PATCH] warnings are now on stderr --- command/e2etest/init_test.go | 14 +++----------- command/e2etest/provider_dev_test.go | 2 +- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/command/e2etest/init_test.go b/command/e2etest/init_test.go index f59ce0b05..197671398 100644 --- a/command/e2etest/init_test.go +++ b/command/e2etest/init_test.go @@ -250,19 +250,11 @@ func TestInitProviders_pluginCache(t *testing.T) { // convert the slashes if building for windows. p := filepath.FromSlash("./cache") cmd.Env = append(cmd.Env, "TF_PLUGIN_CACHE_DIR="+p) - cmd.Stdin = nil - cmd.Stderr = &bytes.Buffer{} - err = cmd.Run() if err != nil { t.Errorf("unexpected error: %s", err) } - stderr := cmd.Stderr.(*bytes.Buffer).String() - if stderr != "" { - t.Errorf("unexpected stderr output:\n%s\n", stderr) - } - path := filepath.FromSlash(fmt.Sprintf(".terraform/providers/registry.terraform.io/hashicorp/template/2.1.0/%s_%s/terraform-provider-template_v2.1.0_x4", runtime.GOOS, runtime.GOARCH)) content, err := tf.ReadFile(path) if err != nil { @@ -375,13 +367,13 @@ func TestInitProviderWarnings(t *testing.T) { tf := e2e.NewBinary(terraformBin, fixturePath) defer tf.Close() - stdout, _, err := tf.Run("init") + _, stderr, err := tf.Run("init") if err == nil { t.Fatal("expected error, got success") } - if !strings.Contains(stdout, "This provider is archived and no longer needed. The terraform_remote_state\ndata source is built into the latest Terraform release.") { - t.Errorf("expected warning message is missing from output:\n%s", stdout) + if !strings.Contains(stderr, "This provider is archived and no longer needed. The terraform_remote_state\ndata source is built into the latest Terraform release.") { + t.Errorf("expected warning message is missing from output:\n%s", stderr) } } diff --git a/command/e2etest/provider_dev_test.go b/command/e2etest/provider_dev_test.go index 723591dbe..3c779c5a3 100644 --- a/command/e2etest/provider_dev_test.go +++ b/command/e2etest/provider_dev_test.go @@ -70,7 +70,7 @@ func TestProviderDevOverrides(t *testing.T) { if got, want := stdout, `The configuration is valid, but`; !strings.Contains(got, want) { t.Errorf("stdout doesn't include the success message\nwant: %s\n%s", want, got) } - if got, want := stdout, `Provider development overrides are in effect`; !strings.Contains(got, want) { + if got, want := stderr, `Provider development overrides are in effect`; !strings.Contains(got, want) { t.Errorf("stdout doesn't include the warning about development overrides\nwant: %s\n%s", want, got) } }