Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Commit

Permalink
reproduce #37
Browse files Browse the repository at this point in the history
  • Loading branch information
catsby committed Jun 11, 2021
1 parent 6834347 commit 6a307c8
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions framework/resource/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,38 @@ func TestManagerDestroyAll_noDestroyFunc(t *testing.T) {
// Ensure we destroyed
require.Equal([]string{"B"}, destroyOrder)
}

func TestManagerDestroyAll_noCreateAll(t *testing.T) {
require := require.New(t)

// init is a function so that we can reinitialize an empty manager
var destroyOrder []string
init := func() *Manager {
return NewManager(
WithResource(NewResource(
WithName("A"),
WithState(&testproto.Data{}),
WithCreate(func(s *testproto.Data, v int32) error {
s.Number = v
return nil
}),
WithDestroy(func(s *testproto.Data) error {
destroyOrder = append(destroyOrder, "A")
return nil
}),
)),
)
}

// Create
m := init()
m.Resource("A").SetState(&testproto.Data{
Number: 42,
})

// Destroy
require.NoError(m.DestroyAll())

// Ensure we destroyed
require.Equal([]string{"A"}, destroyOrder)
}

0 comments on commit 6a307c8

Please sign in to comment.