From 54531473816e149134fedde3de740ab93755d2ea Mon Sep 17 00:00:00 2001 From: Owen Tuz Date: Wed, 30 Sep 2020 09:30:02 +0100 Subject: [PATCH] Fix bad string match that was causing TestInitProviderNotFound to fail on Macs The tmp directory path is longer on Macs than other systems and was wrapping across lines when printed, breaking the string match in the test. Fix suggested by @apparentlymart is to add two spaces before the leading '-' when printing to prevent the diagnostic renderer wrapping the line. --- command/e2etest/init_test.go | 2 +- command/init.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/command/e2etest/init_test.go b/command/e2etest/init_test.go index ed5e112d5..f0b16a8e4 100644 --- a/command/e2etest/init_test.go +++ b/command/e2etest/init_test.go @@ -357,7 +357,7 @@ func TestInitProviderNotFound(t *testing.T) { t.Fatal("expected error, got success") } - if !strings.Contains(stderr, "provider registry.terraform.io/hashicorp/nonexist was not\nfound in any of the search locations\n\n- "+pluginDir) { + if !strings.Contains(stderr, "provider registry.terraform.io/hashicorp/nonexist was not\nfound in any of the search locations\n\n - "+pluginDir) { t.Errorf("expected error message is missing from output:\n%s", stderr) } }) diff --git a/command/init.go b/command/init.go index 392fb5e14..ecd4cc388 100644 --- a/command/init.go +++ b/command/init.go @@ -505,7 +505,7 @@ func (c *InitCommand) getProviders(config *configs.Config, state *states.State, sources := errorTy.Sources displaySources := make([]string, len(sources)) for i, source := range sources { - displaySources[i] = fmt.Sprintf("- %s", source) + displaySources[i] = fmt.Sprintf(" - %s", source) } diags = diags.Append(tfdiags.Sourceless( tfdiags.Error,