github.com/anuaimi/terraform@v0.6.4-0.20150904235404-2bf9aec61da8/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  	PostStateUpdateCalled bool
    74  	PostStateUpdateState  *State
    75  	PostStateUpdateReturn HookAction
    76  	PostStateUpdateError  error
    77  }
    78  
    79  func (h *MockHook) PreApply(n *InstanceInfo, s *InstanceState, d *InstanceDiff) (HookAction, error) {
    80  	h.PreApplyCalled = true
    81  	h.PreApplyInfo = n
    82  	h.PreApplyDiff = d
    83  	h.PreApplyState = s
    84  	return h.PreApplyReturn, h.PreApplyError
    85  }
    86  
    87  func (h *MockHook) PostApply(n *InstanceInfo, s *InstanceState, e error) (HookAction, error) {
    88  	h.PostApplyCalled = true
    89  	h.PostApplyInfo = n
    90  	h.PostApplyState = s
    91  	h.PostApplyError = e
    92  	return h.PostApplyReturn, h.PostApplyReturnError
    93  }
    94  
    95  func (h *MockHook) PreDiff(n *InstanceInfo, s *InstanceState) (HookAction, error) {
    96  	h.PreDiffCalled = true
    97  	h.PreDiffInfo = n
    98  	h.PreDiffState = s
    99  	return h.PreDiffReturn, h.PreDiffError
   100  }
   101  
   102  func (h *MockHook) PostDiff(n *InstanceInfo, d *InstanceDiff) (HookAction, error) {
   103  	h.PostDiffCalled = true
   104  	h.PostDiffInfo = n
   105  	h.PostDiffDiff = d
   106  	return h.PostDiffReturn, h.PostDiffError
   107  }
   108  
   109  func (h *MockHook) PreProvisionResource(n *InstanceInfo, s *InstanceState) (HookAction, error) {
   110  	h.PreProvisionResourceCalled = true
   111  	h.PreProvisionResourceInfo = n
   112  	h.PreProvisionInstanceState = s
   113  	return h.PreProvisionResourceReturn, h.PreProvisionResourceError
   114  }
   115  
   116  func (h *MockHook) PostProvisionResource(n *InstanceInfo, s *InstanceState) (HookAction, error) {
   117  	h.PostProvisionResourceCalled = true
   118  	h.PostProvisionResourceInfo = n
   119  	h.PostProvisionInstanceState = s
   120  	return h.PostProvisionResourceReturn, h.PostProvisionResourceError
   121  }
   122  
   123  func (h *MockHook) PreProvision(n *InstanceInfo, provId string) (HookAction, error) {
   124  	h.PreProvisionCalled = true
   125  	h.PreProvisionInfo = n
   126  	h.PreProvisionProvisionerId = provId
   127  	return h.PreProvisionReturn, h.PreProvisionError
   128  }
   129  
   130  func (h *MockHook) PostProvision(n *InstanceInfo, provId string) (HookAction, error) {
   131  	h.PostProvisionCalled = true
   132  	h.PostProvisionInfo = n
   133  	h.PostProvisionProvisionerId = provId
   134  	return h.PostProvisionReturn, h.PostProvisionError
   135  }
   136  
   137  func (h *MockHook) ProvisionOutput(
   138  	n *InstanceInfo,
   139  	provId string,
   140  	msg string) {
   141  	h.ProvisionOutputCalled = true
   142  	h.ProvisionOutputInfo = n
   143  	h.ProvisionOutputProvisionerId = provId
   144  	h.ProvisionOutputMessage = msg
   145  }
   146  
   147  func (h *MockHook) PreRefresh(n *InstanceInfo, s *InstanceState) (HookAction, error) {
   148  	h.PreRefreshCalled = true
   149  	h.PreRefreshInfo = n
   150  	h.PreRefreshState = s
   151  	return h.PreRefreshReturn, h.PreRefreshError
   152  }
   153  
   154  func (h *MockHook) PostRefresh(n *InstanceInfo, s *InstanceState) (HookAction, error) {
   155  	h.PostRefreshCalled = true
   156  	h.PostRefreshInfo = n
   157  	h.PostRefreshState = s
   158  	return h.PostRefreshReturn, h.PostRefreshError
   159  }
   160  
   161  func (h *MockHook) PostStateUpdate(s *State) (HookAction, error) {
   162  	h.PostStateUpdateCalled = true
   163  	h.PostStateUpdateState = s
   164  	return h.PostStateUpdateReturn, h.PostStateUpdateError
   165  }