terraform/state/local_test.go

43 lines
773 B
Go
Raw Normal View History

2015-02-21 20:52:55 +01:00
package state
import (
"io/ioutil"
"os"
"testing"
"github.com/hashicorp/terraform/terraform"
)
func TestLocalState(t *testing.T) {
2015-02-21 21:25:10 +01:00
ls := testLocalState(t)
defer os.Remove(ls.Path)
TestState(t, ls)
}
func TestLocalState_impl(t *testing.T) {
var _ StateReader = new(LocalState)
var _ StateWriter = new(LocalState)
var _ StatePersister = new(LocalState)
var _ StateRefresher = new(LocalState)
}
func testLocalState(t *testing.T) *LocalState {
2015-02-21 20:52:55 +01:00
f, err := ioutil.TempFile("", "tf")
if err != nil {
t.Fatalf("err: %s", err)
}
2015-02-21 21:25:10 +01:00
err = terraform.WriteState(TestStateInitial(), f)
2015-02-21 20:52:55 +01:00
f.Close()
if err != nil {
t.Fatalf("err: %s", err)
}
2015-02-21 21:25:10 +01:00
ls := &LocalState{Path: f.Name()}
if err := ls.RefreshState(); err != nil {
t.Fatalf("bad: %s", err)
}
2015-02-21 20:52:55 +01:00
2015-02-21 21:25:10 +01:00
return ls
2015-02-21 20:52:55 +01:00
}