Created
September 22, 2016 01:57
-
-
Save benjamintanweihao/9e30879ecdcbdd9a8b49662b3ed60fcd to your computer and use it in GitHub Desktop.
Mocking in Golang
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
type MockSlackClient2 struct { | |
PostMessageCalled bool | |
Message string | |
Entry *model.Entry | |
Status string | |
postMessage func(string, string, string) | |
postMessageWithMarkdown func(sting, string, string) | |
} | |
func (m MockSlackClient2) PostMessage(message, channel, status string) { | |
m.postMessage(message, channel, status) | |
} | |
func TestIt(t *testing.T) { | |
f := func(m, c, s string) { | |
// if this is called, fail | |
t.Fail() | |
} | |
m := MockSlackClient2{postMessage: f} | |
m.Postmessagewithmarkdown("a", "b", "c") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment