github.com/nov1n/terraform@v0.7.9-0.20161103151050-bf6852f38e28/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  }