opentofu/terraform/hook_mock.go

140 lines
3.8 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
2014-09-17 18:33:24 -05:00
PreApplyDiff *InstanceDiff
PreApplyState *InstanceState
2014-06-27 00:09:16 -05:00
PreApplyReturn HookAction
PreApplyError error
PostApplyCalled bool
PostApplyId string
PostApplyState *InstanceState
PostApplyError error
PostApplyReturn HookAction
PostApplyReturnError error
2014-06-27 00:09:16 -05:00
2014-06-26 19:17:10 -05:00
PreDiffCalled bool
PreDiffId string
PreDiffState *InstanceState
2014-06-26 19:17:10 -05:00
PreDiffReturn HookAction
PreDiffError error
PostDiffCalled bool
PostDiffId string
2014-09-17 18:33:24 -05:00
PostDiffDiff *InstanceDiff
2014-06-26 19:17:10 -05:00
PostDiffReturn HookAction
PostDiffError error
2014-07-27 11:00:34 -05:00
PreProvisionResourceCalled bool
PreProvisionResourceId string
PreProvisionInstanceState *InstanceState
2014-07-27 11:00:34 -05:00
PreProvisionResourceReturn HookAction
PreProvisionResourceError error
PostProvisionResourceCalled bool
PostProvisionResourceId string
PostProvisionInstanceState *InstanceState
2014-07-27 11:00:34 -05:00
PostProvisionResourceReturn HookAction
PostProvisionResourceError error
PreProvisionCalled bool
PreProvisionId string
PreProvisionProvisionerId string
PreProvisionReturn HookAction
PreProvisionError error
PostProvisionCalled bool
PostProvisionId string
PostProvisionProvisionerId string
PostProvisionReturn HookAction
PostProvisionError error
2014-06-26 18:52:15 -05:00
PostRefreshCalled bool
2014-06-26 19:05:21 -05:00
PostRefreshId string
PostRefreshState *InstanceState
2014-06-26 18:52:15 -05:00
PostRefreshReturn HookAction
PostRefreshError error
PreRefreshCalled bool
2014-06-26 19:05:21 -05:00
PreRefreshId string
PreRefreshState *InstanceState
2014-06-26 18:52:15 -05:00
PreRefreshReturn HookAction
PreRefreshError error
}
2014-09-17 18:33:24 -05:00
func (h *MockHook) PreApply(n string, s *InstanceState, d *InstanceDiff) (HookAction, error) {
2014-06-27 00:09:16 -05:00
h.PreApplyCalled = true
h.PreApplyId = n
h.PreApplyDiff = d
h.PreApplyState = s
return h.PreApplyReturn, h.PreApplyError
}
func (h *MockHook) PostApply(n string, s *InstanceState, e error) (HookAction, error) {
2014-06-27 00:09:16 -05:00
h.PostApplyCalled = true
h.PostApplyId = n
h.PostApplyState = s
h.PostApplyError = e
return h.PostApplyReturn, h.PostApplyReturnError
2014-06-27 00:09:16 -05:00
}
func (h *MockHook) PreDiff(n string, s *InstanceState) (HookAction, error) {
2014-06-26 19:17:10 -05:00
h.PreDiffCalled = true
h.PreDiffId = n
h.PreDiffState = s
return h.PreDiffReturn, h.PreDiffError
}
2014-09-17 18:33:24 -05:00
func (h *MockHook) PostDiff(n string, d *InstanceDiff) (HookAction, error) {
2014-06-26 19:17:10 -05:00
h.PostDiffCalled = true
h.PostDiffId = n
h.PostDiffDiff = d
return h.PostDiffReturn, h.PostDiffError
}
func (h *MockHook) PreProvisionResource(id string, s *InstanceState) (HookAction, error) {
2014-07-27 11:00:34 -05:00
h.PreProvisionResourceCalled = true
h.PreProvisionResourceId = id
h.PreProvisionInstanceState = s
2014-07-27 11:00:34 -05:00
return h.PreProvisionResourceReturn, h.PreProvisionResourceError
}
func (h *MockHook) PostProvisionResource(id string, s *InstanceState) (HookAction, error) {
2014-07-27 11:00:34 -05:00
h.PostProvisionResourceCalled = true
h.PostProvisionResourceId = id
h.PostProvisionInstanceState = s
2014-07-27 11:00:34 -05:00
return h.PostProvisionResourceReturn, h.PostProvisionResourceError
}
func (h *MockHook) PreProvision(id, provId string) (HookAction, error) {
h.PreProvisionCalled = true
h.PreProvisionId = id
h.PreProvisionProvisionerId = provId
return h.PreProvisionReturn, h.PreProvisionError
}
func (h *MockHook) PostProvision(id, provId string) (HookAction, error) {
h.PostProvisionCalled = true
h.PostProvisionId = id
h.PostProvisionProvisionerId = provId
return h.PostProvisionReturn, h.PostProvisionError
}
func (h *MockHook) PreRefresh(n string, s *InstanceState) (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
}
func (h *MockHook) PostRefresh(n string, s *InstanceState) (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
}