diff --git a/pkg/state/state.go b/pkg/state/state.go index c0fbe44..7a226d0 100644 --- a/pkg/state/state.go +++ b/pkg/state/state.go @@ -87,7 +87,7 @@ var ReadStateFile = func(filename string) ([]byte, error) { f, err := os.Open(filename) if err != nil { // return empty json contents if state.json does not exist - return []byte(`{}`), nil + return []byte(`{"resources":{}}`), nil } defer f.Close() @@ -244,6 +244,7 @@ func Keys(resources []Resource) []string { func Open(path string, resourcers []Resourcer) (*State, error) { s := State{ + Self: Self{Resources: map[ID]Resource{}}, path: path, packages: map[ID]Resource{}, mu: sync.RWMutex{}, diff --git a/pkg/state/state_test.go b/pkg/state/state_test.go index d1a88e3..8f4899a 100644 --- a/pkg/state/state_test.go +++ b/pkg/state/state_test.go @@ -45,7 +45,7 @@ func TestOpen(t *testing.T) { }{ "Empty": { filename: "empty.json", - state: &State{path: "empty.json"}, + state: &State{Self: Self{Resources: map[string]Resource{}}, path: "empty.json"}, }, "Open": { filename: "state.json",