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.
This commit is contained in:
Owen Tuz 2020-09-30 09:30:02 +01:00
parent fc94c819e5
commit 5453147381
2 changed files with 2 additions and 2 deletions

View File

@ -357,7 +357,7 @@ func TestInitProviderNotFound(t *testing.T) {
t.Fatal("expected error, got success") 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) t.Errorf("expected error message is missing from output:\n%s", stderr)
} }
}) })

View File

@ -505,7 +505,7 @@ func (c *InitCommand) getProviders(config *configs.Config, state *states.State,
sources := errorTy.Sources sources := errorTy.Sources
displaySources := make([]string, len(sources)) displaySources := make([]string, len(sources))
for i, source := range sources { for i, source := range sources {
displaySources[i] = fmt.Sprintf("- %s", source) displaySources[i] = fmt.Sprintf(" - %s", source)
} }
diags = diags.Append(tfdiags.Sourceless( diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error, tfdiags.Error,