github.com/rancher/moq@v0.0.0-20200712062324-13d1f37d2d77/pkg/moq/testpackages/imports/testdata/gofmt.golden.go (about)

     1  // Code generated by moq; DO NOT EDIT.
     2  // github.com/matryer/moq
     3  
     4  package two
     5  
     6  import (
     7  	"github.com/matryer/moq/pkg/moq/testpackages/imports/one"
     8  	"sync"
     9  )
    10  
    11  var (
    12  	lockDoSomethingMockAnother sync.RWMutex
    13  	lockDoSomethingMockDo      sync.RWMutex
    14  )
    15  
    16  // Ensure, that DoSomethingMock does implement DoSomething.
    17  // If this is not the case, regenerate this file with moq.
    18  var _ DoSomething = &DoSomethingMock{}
    19  
    20  // DoSomethingMock is a mock implementation of DoSomething.
    21  //
    22  //     func TestSomethingThatUsesDoSomething(t *testing.T) {
    23  //
    24  //         // make and configure a mocked DoSomething
    25  //         mockedDoSomething := &DoSomethingMock{
    26  //             AnotherFunc: func(thing one.Thing) error {
    27  // 	               panic("mock out the Another method")
    28  //             },
    29  //             DoFunc: func(thing one.Thing) error {
    30  // 	               panic("mock out the Do method")
    31  //             },
    32  //         }
    33  //
    34  //         // use mockedDoSomething in code that requires DoSomething
    35  //         // and then make assertions.
    36  //
    37  //     }
    38  type DoSomethingMock struct {
    39  	// AnotherFunc mocks the Another method.
    40  	AnotherFunc func(thing one.Thing) error
    41  
    42  	// DoFunc mocks the Do method.
    43  	DoFunc func(thing one.Thing) error
    44  
    45  	// calls tracks calls to the methods.
    46  	calls struct {
    47  		// Another holds details about calls to the Another method.
    48  		Another []struct {
    49  			// Thing is the thing argument value.
    50  			Thing one.Thing
    51  		}
    52  		// Do holds details about calls to the Do method.
    53  		Do []struct {
    54  			// Thing is the thing argument value.
    55  			Thing one.Thing
    56  		}
    57  	}
    58  }
    59  
    60  // Another calls AnotherFunc.
    61  func (mock *DoSomethingMock) Another(thing one.Thing) error {
    62  	if mock.AnotherFunc == nil {
    63  		panic("DoSomethingMock.AnotherFunc: method is nil but DoSomething.Another was just called")
    64  	}
    65  	callInfo := struct {
    66  		Thing one.Thing
    67  	}{
    68  		Thing: thing,
    69  	}
    70  	lockDoSomethingMockAnother.Lock()
    71  	mock.calls.Another = append(mock.calls.Another, callInfo)
    72  	lockDoSomethingMockAnother.Unlock()
    73  	return mock.AnotherFunc(thing)
    74  }
    75  
    76  // AnotherCalls gets all the calls that were made to Another.
    77  // Check the length with:
    78  //     len(mockedDoSomething.AnotherCalls())
    79  func (mock *DoSomethingMock) AnotherCalls() []struct {
    80  	Thing one.Thing
    81  } {
    82  	var calls []struct {
    83  		Thing one.Thing
    84  	}
    85  	lockDoSomethingMockAnother.RLock()
    86  	calls = mock.calls.Another
    87  	lockDoSomethingMockAnother.RUnlock()
    88  	return calls
    89  }
    90  
    91  // Do calls DoFunc.
    92  func (mock *DoSomethingMock) Do(thing one.Thing) error {
    93  	if mock.DoFunc == nil {
    94  		panic("DoSomethingMock.DoFunc: method is nil but DoSomething.Do was just called")
    95  	}
    96  	callInfo := struct {
    97  		Thing one.Thing
    98  	}{
    99  		Thing: thing,
   100  	}
   101  	lockDoSomethingMockDo.Lock()
   102  	mock.calls.Do = append(mock.calls.Do, callInfo)
   103  	lockDoSomethingMockDo.Unlock()
   104  	return mock.DoFunc(thing)
   105  }
   106  
   107  // DoCalls gets all the calls that were made to Do.
   108  // Check the length with:
   109  //     len(mockedDoSomething.DoCalls())
   110  func (mock *DoSomethingMock) DoCalls() []struct {
   111  	Thing one.Thing
   112  } {
   113  	var calls []struct {
   114  		Thing one.Thing
   115  	}
   116  	lockDoSomethingMockDo.RLock()
   117  	calls = mock.calls.Do
   118  	lockDoSomethingMockDo.RUnlock()
   119  	return calls
   120  }