mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
core: TestContext2Apply_createBeforeDestroy_hook
The instnace info ID has changed, and no longer reflects the type of node. Record the state to determine apply order for this test.
This commit is contained in:
parent
403abb52b9
commit
aa07f34dbe
@ -1008,8 +1008,9 @@ func TestContext2Apply_createBeforeDestroy_hook(t *testing.T) {
|
|||||||
var actualLock sync.Mutex
|
var actualLock sync.Mutex
|
||||||
h.PostApplyFn = func(n *InstanceInfo, s *InstanceState, e error) (HookAction, error) {
|
h.PostApplyFn = func(n *InstanceInfo, s *InstanceState, e error) (HookAction, error) {
|
||||||
actualLock.Lock()
|
actualLock.Lock()
|
||||||
|
|
||||||
defer actualLock.Unlock()
|
defer actualLock.Unlock()
|
||||||
actual = append(actual, n.Id)
|
actual = append(actual, s.String())
|
||||||
return HookActionContinue, nil
|
return HookActionContinue, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1034,7 +1035,11 @@ func TestContext2Apply_createBeforeDestroy_hook(t *testing.T) {
|
|||||||
t.Fatalf("apply errors: %s", diags.Err())
|
t.Fatalf("apply errors: %s", diags.Err())
|
||||||
}
|
}
|
||||||
|
|
||||||
expected := []string{"aws_instance.bar", "aws_instance.bar (deposed #0)"}
|
expected := []string{
|
||||||
|
"ID = foo\nrequire_new = xyz\ntype = aws_instance\nTainted = false\n",
|
||||||
|
"<not created>",
|
||||||
|
}
|
||||||
|
|
||||||
if !reflect.DeepEqual(actual, expected) {
|
if !reflect.DeepEqual(actual, expected) {
|
||||||
t.Fatalf("bad: %#v", actual)
|
t.Fatalf("bad: %#v", actual)
|
||||||
}
|
}
|
||||||
|
@ -1770,13 +1770,19 @@ func (s *InstanceState) MergeDiff(d *InstanceDiff) *InstanceState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *InstanceState) String() string {
|
func (s *InstanceState) String() string {
|
||||||
|
notCreated := "<not created>"
|
||||||
|
|
||||||
|
if s == nil {
|
||||||
|
return notCreated
|
||||||
|
}
|
||||||
|
|
||||||
s.Lock()
|
s.Lock()
|
||||||
defer s.Unlock()
|
defer s.Unlock()
|
||||||
|
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
|
|
||||||
if s == nil || s.ID == "" {
|
if s.ID == "" {
|
||||||
return "<not created>"
|
return notCreated
|
||||||
}
|
}
|
||||||
|
|
||||||
buf.WriteString(fmt.Sprintf("ID = %s\n", s.ID))
|
buf.WriteString(fmt.Sprintf("ID = %s\n", s.ID))
|
||||||
|
Loading…
Reference in New Issue
Block a user