Created
July 11, 2017 21:25
-
-
Save matryer/b55bcf66c3b7eeb403577625eefe2066 to your computer and use it in GitHub Desktop.
Moq generated mock of a simple interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sending | |
// AUTOGENERATED BY MOQ - DO NOT EDIT | |
// github.com/matryer/moq | |
import ( | |
"sync" | |
) | |
var ( | |
lockSenderMockSend sync.RWMutex | |
) | |
// SenderMock is a mock implementation of Sender. | |
// | |
// func TestSomethingThatUsesSender(t *testing.T) { | |
// | |
// // make and configure a mocked Sender | |
// mockedSender := &SenderMock{ | |
// SendFunc: func(to string, subject string, body string) error { | |
// panic("TODO: mock out the Send method") | |
// }, | |
// } | |
// | |
// // TODO: use mockedSender in code that requires Sender | |
// // and then make assertions. | |
// | |
// } | |
type SenderMock struct { | |
// SendFunc mocks the Send method. | |
SendFunc func(to string, subject string, body string) error | |
// calls tracks calls to the methods. | |
calls struct { | |
// Send holds details about calls to the Send method. | |
Send []struct { | |
// To is the to argument value. | |
To string | |
// Subject is the subject argument value. | |
Subject string | |
// Body is the body argument value. | |
Body string | |
} | |
} | |
} | |
// Send calls SendFunc. | |
func (mock *SenderMock) Send(to string, subject string, body string) error { | |
if mock.SendFunc == nil { | |
panic("moq: SenderMock.SendFunc is nil but Sender.Send was just called") | |
} | |
callInfo := struct { | |
To string | |
Subject string | |
Body string | |
}{ | |
To: to, | |
Subject: subject, | |
Body: body, | |
} | |
lockSenderMockSend.Lock() | |
mock.calls.Send = append(mock.calls.Send, callInfo) | |
lockSenderMockSend.Unlock() | |
return mock.SendFunc(to, subject, body) | |
} | |
// SendCalls gets all the calls that were made to Send. | |
// Check the length with: | |
// len(mockedSender.SendCalls()) | |
func (mock *SenderMock) SendCalls() []struct { | |
To string | |
Subject string | |
Body string | |
} { | |
var calls []struct { | |
To string | |
Subject string | |
Body string | |
} | |
lockSenderMockSend.RLock() | |
calls = mock.calls.Send | |
lockSenderMockSend.RUnlock() | |
return calls | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment