opentofu/terraform/hook_mock.go

86 lines
2.1 KiB
Go
Raw Normal View History

2014-06-26 18:52:15 -05:00
package terraform
// MockHook is an implementation of Hook that can be used for tests.
// It records all of its function calls.
type MockHook struct {
2014-06-27 00:09:16 -05:00
PreApplyCalled bool
PreApplyId string
PreApplyDiff *ResourceDiff
PreApplyState *ResourceState
PreApplyReturn HookAction
PreApplyError error
PostApplyCalled bool
PostApplyId string
PostApplyState *ResourceState
PostApplyReturn HookAction
PostApplyError error
2014-06-26 19:17:10 -05:00
PreDiffCalled bool
PreDiffId string
PreDiffState *ResourceState
PreDiffReturn HookAction
PreDiffError error
PostDiffCalled bool
PostDiffId string
PostDiffDiff *ResourceDiff
PostDiffReturn HookAction
PostDiffError error
2014-06-26 18:52:15 -05:00
PostRefreshCalled bool
2014-06-26 19:05:21 -05:00
PostRefreshId string
2014-06-26 18:52:15 -05:00
PostRefreshState *ResourceState
PostRefreshReturn HookAction
PostRefreshError error
PreRefreshCalled bool
2014-06-26 19:05:21 -05:00
PreRefreshId string
2014-06-26 18:52:15 -05:00
PreRefreshState *ResourceState
PreRefreshReturn HookAction
PreRefreshError error
}
2014-06-27 00:09:16 -05:00
func (h *MockHook) PreApply(n string, s *ResourceState, d *ResourceDiff) (HookAction, error) {
h.PreApplyCalled = true
h.PreApplyId = n
h.PreApplyDiff = d
h.PreApplyState = s
return h.PreApplyReturn, h.PreApplyError
}
func (h *MockHook) PostApply(n string, s *ResourceState) (HookAction, error) {
h.PostApplyCalled = true
h.PostApplyId = n
h.PostApplyState = s
return h.PostApplyReturn, h.PostApplyError
}
2014-06-26 19:17:10 -05:00
func (h *MockHook) PreDiff(n string, s *ResourceState) (HookAction, error) {
h.PreDiffCalled = true
h.PreDiffId = n
h.PreDiffState = s
return h.PreDiffReturn, h.PreDiffError
}
func (h *MockHook) PostDiff(n string, d *ResourceDiff) (HookAction, error) {
h.PostDiffCalled = true
h.PostDiffId = n
h.PostDiffDiff = d
return h.PostDiffReturn, h.PostDiffError
}
2014-06-26 19:05:21 -05:00
func (h *MockHook) PreRefresh(n string, s *ResourceState) (HookAction, error) {
2014-06-26 18:52:15 -05:00
h.PreRefreshCalled = true
2014-06-26 19:05:21 -05:00
h.PreRefreshId = n
2014-06-26 18:52:15 -05:00
h.PreRefreshState = s
return h.PreRefreshReturn, h.PreRefreshError
}
2014-06-26 19:05:21 -05:00
func (h *MockHook) PostRefresh(n string, s *ResourceState) (HookAction, error) {
2014-06-26 18:52:15 -05:00
h.PostRefreshCalled = true
2014-06-26 19:05:21 -05:00
h.PostRefreshId = n
2014-06-26 18:52:15 -05:00
h.PostRefreshState = s
return h.PostRefreshReturn, h.PostRefreshError
}