Skip to content

Commit

Permalink
backport of commit b45b253
Browse files Browse the repository at this point in the history
  • Loading branch information
kmoe committed Jul 15, 2022
1 parent 2c609a6 commit be3bec8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
28 changes: 28 additions & 0 deletions internal/command/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,34 @@ func TestShow_planWithNonDefaultStateLineage(t *testing.T) {
}
}

func TestShow_corruptStatefile(t *testing.T) {
td := t.TempDir()
inputDir := "testdata/show-corrupt-statefile"
testCopyDir(t, inputDir, td)
defer testChdir(t, td)()

view, done := testView(t)
c := &ShowCommand{
Meta: Meta{
testingOverrides: metaOverridesForProvider(testProvider()),
View: view,
},
}

code := c.Run([]string{})
output := done(t)

if code != 1 {
t.Fatalf("unexpected exit status %d; want 1\ngot: %s", code, output.Stdout())
}

got := output.Stderr()
want := `Unsupported state file format`
if !strings.Contains(got, want) {
t.Errorf("unexpected output\ngot: %s\nwant:\n%s", got, want)
}
}

// showFixtureSchema returns a schema suitable for processing the configuration
// in testdata/show. This schema should be assigned to a mock provider
// named "test".
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invalid

0 comments on commit be3bec8

Please sign in to comment.