diff --git a/command/command_test.go b/command/command_test.go index a416256f86..1507b5b96f 100644 --- a/command/command_test.go +++ b/command/command_test.go @@ -160,7 +160,6 @@ func testReadPlan(t *testing.T, path string) *terraform.Plan { // testState returns a test State structure that we use for a lot of tests. func testState() *terraform.State { state := &terraform.State{ - Version: 2, Modules: []*terraform.ModuleState{ &terraform.ModuleState{ Path: []string{"root"}, @@ -177,20 +176,7 @@ func testState() *terraform.State { }, } state.Init() - - // Write and read the state so that it is properly initialized. We - // do this since we didn't call the normal NewState constructor. - var buf bytes.Buffer - if err := terraform.WriteState(state, &buf); err != nil { - panic(err) - } - - result, err := terraform.ReadState(&buf) - if err != nil { - panic(err) - } - - return result + return state } func testStateFile(t *testing.T, s *terraform.State) string { diff --git a/terraform/state.go b/terraform/state.go index a8fc5277be..0c46194d6f 100644 --- a/terraform/state.go +++ b/terraform/state.go @@ -677,6 +677,7 @@ func (s *State) init() { if s.Version == 0 { s.Version = StateVersion } + if s.moduleByPath(rootModulePath) == nil { s.addModule(rootModulePath) }