command: Fix tests for "terraform fmt" command

Some underlying assumptions have shifted here, so although the behavior
is still broadly the same we need to accommodate some different details.
pull/19086/head
Martin Atkins 8 years ago
parent 74582447bb
commit c0baedac84

@ -29,7 +29,7 @@ func TestFmt_errorReporting(t *testing.T) {
t.Fatalf("wrong exit code. errors: \n%s", ui.ErrorWriter.String())
}
expected := fmt.Sprintf("Error running fmt: stat %s: no such file or directory", dummy_file)
expected := "There is no configuration directory at"
if actual := ui.ErrorWriter.String(); !strings.Contains(actual, expected) {
t.Fatalf("expected:\n%s\n\nto include: %q", actual, expected)
}
@ -106,9 +106,14 @@ func TestFmt_directoryArg(t *testing.T) {
t.Fatalf("wrong exit code. errors: \n%s", ui.ErrorWriter.String())
}
expected := fmt.Sprintf("%s\n", filepath.Join(tempDir, fmtFixture.filename))
if actual := ui.OutputWriter.String(); actual != expected {
t.Fatalf("got: %q\nexpected: %q", actual, expected)
got, err := filepath.Abs(strings.TrimSpace(ui.OutputWriter.String()))
if err != nil {
t.Fatal(err)
}
want := filepath.Join(tempDir, fmtFixture.filename)
if got != want {
t.Fatalf("wrong output\ngot: %s\nwant: %s", got, want)
}
}

Loading…
Cancel
Save