github.com/hs0210/hashicorp-terraform@v0.11.12-beta1/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/terraform"
     8  )
     9  
    10  func TestStateHook_impl(t *testing.T) {
    11  	var _ terraform.Hook = new(StateHook)
    12  }
    13  
    14  func TestStateHook(t *testing.T) {
    15  	is := &state.InmemState{}
    16  	var hook terraform.Hook = &StateHook{State: is}
    17  
    18  	s := state.TestStateInitial()
    19  	action, err := hook.PostStateUpdate(s)
    20  	if err != nil {
    21  		t.Fatalf("err: %s", err)
    22  	}
    23  	if action != terraform.HookActionContinue {
    24  		t.Fatalf("bad: %v", action)
    25  	}
    26  	if !is.State().Equal(s) {
    27  		t.Fatalf("bad state: %#v", is.State())
    28  	}
    29  }