github.com/ggriffiths/terraform@v0.9.0-beta1.0.20170222213024-79c4935604cb/command/state_pull_test.go (about) 1 package command 2 3 import ( 4 "strings" 5 "testing" 6 7 "github.com/mitchellh/cli" 8 ) 9 10 func TestStatePull(t *testing.T) { 11 tmp, cwd := testCwd(t) 12 defer testFixCwd(t, tmp, cwd) 13 14 // Create some legacy remote state 15 legacyState := testState() 16 _, srv := testRemoteState(t, legacyState, 200) 17 defer srv.Close() 18 testStateFileRemote(t, legacyState) 19 20 p := testProvider() 21 ui := new(cli.MockUi) 22 c := &StatePullCommand{ 23 Meta: Meta{ 24 ContextOpts: testCtxConfig(p), 25 Ui: ui, 26 }, 27 } 28 29 args := []string{} 30 if code := c.Run(args); code != 0 { 31 t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String()) 32 } 33 34 expected := "test_instance.foo" 35 actual := ui.OutputWriter.String() 36 if !strings.Contains(actual, expected) { 37 t.Fatalf("expected:\n%s\n\nto include: %q", actual, expected) 38 } 39 }