github.com/adrian-bl/terraform@v0.7.0-rc2.0.20160705220747-de0a34fc3517/terraform/hook_mock.go (about)

     1  package terraform
     2  
     3  // MockHook is an implementation of Hook that can be used for tests.
     4  // It records all of its function calls.
     5  type MockHook struct {
     6  	PreApplyCalled bool
     7  	PreApplyInfo   *InstanceInfo
     8  	PreApplyDiff   *InstanceDiff
     9  	PreApplyState  *InstanceState
    10  	PreApplyReturn HookAction
    11  	PreApplyError  error
    12  
    13  	PostApplyCalled      bool
    14  	PostApplyInfo        *InstanceInfo
    15  	PostApplyState       *InstanceState
    16  	PostApplyError       error
    17  	PostApplyReturn      HookAction
    18  	PostApplyReturnError error
    19  
    20  	PreDiffCalled bool
    21  	PreDiffInfo   *InstanceInfo
    22  	PreDiffState  *InstanceState
    23  	PreDiffReturn HookAction
    24  	PreDiffError  error
    25  
    26  	PostDiffCalled bool
    27  	PostDiffInfo   *InstanceInfo
    28  	PostDiffDiff   *InstanceDiff
    29  	PostDiffReturn HookAction
    30  	PostDiffError  error
    31  
    32  	PreProvisionResourceCalled bool
    33  	PreProvisionResourceInfo   *InstanceInfo
    34  	PreProvisionInstanceState  *InstanceState
    35  	PreProvisionResourceReturn HookAction
    36  	PreProvisionResourceError  error
    37  
    38  	PostProvisionResourceCalled bool
    39  	PostProvisionResourceInfo   *InstanceInfo
    40  	PostProvisionInstanceState  *InstanceState
    41  	PostProvisionResourceReturn HookAction
    42  	PostProvisionResourceError  error
    43  
    44  	PreProvisionCalled        bool
    45  	PreProvisionInfo          *InstanceInfo
    46  	PreProvisionProvisionerId string
    47  	PreProvisionReturn        HookAction
    48  	PreProvisionError         error
    49  
    50  	PostProvisionCalled        bool
    51  	PostProvisionInfo          *InstanceInfo
    52  	PostProvisionProvisionerId string
    53  	PostProvisionReturn        HookAction
    54  	PostProvisionError         error
    55  
    56  	ProvisionOutputCalled        bool
    57  	ProvisionOutputInfo          *InstanceInfo
    58  	ProvisionOutputProvisionerId string
    59  	ProvisionOutputMessage       string
    60  
    61  	PostRefreshCalled bool
    62  	PostRefreshInfo   *InstanceInfo
    63  	PostRefreshState  *InstanceState
    64  	PostRefreshReturn HookAction
    65  	PostRefreshError  error
    66  
    67  	PreRefreshCalled bool
    68  	PreRefreshInfo   *InstanceInfo
    69  	PreRefreshState  *InstanceState
    70  	PreRefreshReturn HookAction
    71  	PreRefreshError  error
    72  
    73  	PreImportStateCalled bool
    74  	PreImportStateInfo   *InstanceInfo
    75  	PreImportStateId     string
    76  	PreImportStateReturn HookAction
    77  	PreImportStateError  error
    78  
    79  	PostImportStateCalled bool
    80  	PostImportStateInfo   *InstanceInfo
    81  	PostImportStateState  []*InstanceState
    82  	PostImportStateReturn HookAction
    83  	PostImportStateError  error
    84  
    85  	PostStateUpdateCalled bool
    86  	PostStateUpdateState  *State
    87  	PostStateUpdateReturn HookAction
    88  	PostStateUpdateError  error
    89  }
    90  
    91  func (h *MockHook) PreApply(n *InstanceInfo, s *InstanceState, d *InstanceDiff) (HookAction, error) {
    92  	h.PreApplyCalled = true
    93  	h.PreApplyInfo = n
    94  	h.PreApplyDiff = d
    95  	h.PreApplyState = s
    96  	return h.PreApplyReturn, h.PreApplyError
    97  }
    98  
    99  func (h *MockHook) PostApply(n *InstanceInfo, s *InstanceState, e error) (HookAction, error) {
   100  	h.PostApplyCalled = true
   101  	h.PostApplyInfo = n
   102  	h.PostApplyState = s
   103  	h.PostApplyError = e
   104  	return h.PostApplyReturn, h.PostApplyReturnError
   105  }
   106  
   107  func (h *MockHook) PreDiff(n *InstanceInfo, s *InstanceState) (HookAction, error) {
   108  	h.PreDiffCalled = true
   109  	h.PreDiffInfo = n
   110  	h.PreDiffState = s
   111  	return h.PreDiffReturn, h.PreDiffError
   112  }
   113  
   114  func (h *MockHook) PostDiff(n *InstanceInfo, d *InstanceDiff) (HookAction, error) {
   115  	h.PostDiffCalled = true
   116  	h.PostDiffInfo = n
   117  	h.PostDiffDiff = d
   118  	return h.PostDiffReturn, h.PostDiffError
   119  }
   120  
   121  func (h *MockHook) PreProvisionResource(n *InstanceInfo, s *InstanceState) (HookAction, error) {
   122  	h.PreProvisionResourceCalled = true
   123  	h.PreProvisionResourceInfo = n
   124  	h.PreProvisionInstanceState = s
   125  	return h.PreProvisionResourceReturn, h.PreProvisionResourceError
   126  }
   127  
   128  func (h *MockHook) PostProvisionResource(n *InstanceInfo, s *InstanceState) (HookAction, error) {
   129  	h.PostProvisionResourceCalled = true
   130  	h.PostProvisionResourceInfo = n
   131  	h.PostProvisionInstanceState = s
   132  	return h.PostProvisionResourceReturn, h.PostProvisionResourceError
   133  }
   134  
   135  func (h *MockHook) PreProvision(n *InstanceInfo, provId string) (HookAction, error) {
   136  	h.PreProvisionCalled = true
   137  	h.PreProvisionInfo = n
   138  	h.PreProvisionProvisionerId = provId
   139  	return h.PreProvisionReturn, h.PreProvisionError
   140  }
   141  
   142  func (h *MockHook) PostProvision(n *InstanceInfo, provId string) (HookAction, error) {
   143  	h.PostProvisionCalled = true
   144  	h.PostProvisionInfo = n
   145  	h.PostProvisionProvisionerId = provId
   146  	return h.PostProvisionReturn, h.PostProvisionError
   147  }
   148  
   149  func (h *MockHook) ProvisionOutput(
   150  	n *InstanceInfo,
   151  	provId string,
   152  	msg string) {
   153  	h.ProvisionOutputCalled = true
   154  	h.ProvisionOutputInfo = n
   155  	h.ProvisionOutputProvisionerId = provId
   156  	h.ProvisionOutputMessage = msg
   157  }
   158  
   159  func (h *MockHook) PreRefresh(n *InstanceInfo, s *InstanceState) (HookAction, error) {
   160  	h.PreRefreshCalled = true
   161  	h.PreRefreshInfo = n
   162  	h.PreRefreshState = s
   163  	return h.PreRefreshReturn, h.PreRefreshError
   164  }
   165  
   166  func (h *MockHook) PostRefresh(n *InstanceInfo, s *InstanceState) (HookAction, error) {
   167  	h.PostRefreshCalled = true
   168  	h.PostRefreshInfo = n
   169  	h.PostRefreshState = s
   170  	return h.PostRefreshReturn, h.PostRefreshError
   171  }
   172  
   173  func (h *MockHook) PreImportState(info *InstanceInfo, id string) (HookAction, error) {
   174  	h.PreImportStateCalled = true
   175  	h.PreImportStateInfo = info
   176  	h.PreImportStateId = id
   177  	return h.PreImportStateReturn, h.PreImportStateError
   178  }
   179  
   180  func (h *MockHook) PostImportState(info *InstanceInfo, s []*InstanceState) (HookAction, error) {
   181  	h.PostImportStateCalled = true
   182  	h.PostImportStateInfo = info
   183  	h.PostImportStateState = s
   184  	return h.PostImportStateReturn, h.PostImportStateError
   185  }
   186  
   187  func (h *MockHook) PostStateUpdate(s *State) (HookAction, error) {
   188  	h.PostStateUpdateCalled = true
   189  	h.PostStateUpdateState = s
   190  	return h.PostStateUpdateReturn, h.PostStateUpdateError
   191  }