github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/backend/local/hook_state_test.go (about) 1 package local 2 3 import ( 4 "testing" 5 6 "github.com/hashicorp/terraform/state" 7 "github.com/hashicorp/terraform/states/statemgr" 8 "github.com/hashicorp/terraform/terraform" 9 ) 10 11 func TestStateHook_impl(t *testing.T) { 12 var _ terraform.Hook = new(StateHook) 13 } 14 15 func TestStateHook(t *testing.T) { 16 is := statemgr.NewTransientInMemory(nil) 17 var hook terraform.Hook = &StateHook{StateMgr: is} 18 19 s := state.TestStateInitial() 20 action, err := hook.PostStateUpdate(s) 21 if err != nil { 22 t.Fatalf("err: %s", err) 23 } 24 if action != terraform.HookActionContinue { 25 t.Fatalf("bad: %v", action) 26 } 27 if !is.State().Equal(s) { 28 t.Fatalf("bad state: %#v", is.State()) 29 } 30 }