github.com/aznashwan/terraform@v0.4.3-0.20151118032030-21f93ca4558d/state/backup_test.go (about) 1 package state 2 3 import ( 4 "io/ioutil" 5 "os" 6 "testing" 7 ) 8 9 func TestBackupState(t *testing.T) { 10 f, err := ioutil.TempFile("", "tf") 11 if err != nil { 12 t.Fatalf("err: %s", err) 13 } 14 f.Close() 15 defer os.Remove(f.Name()) 16 17 ls := testLocalState(t) 18 defer os.Remove(ls.Path) 19 TestState(t, &BackupState{ 20 Real: ls, 21 Path: f.Name(), 22 }) 23 24 if fi, err := os.Stat(f.Name()); err != nil { 25 t.Fatalf("err: %s", err) 26 } else if fi.Size() == 0 { 27 t.Fatalf("bad: %d", fi.Size()) 28 } 29 }