Skip to content

Instantly share code, notes, and snippets.

@benjamintanweihao
Created September 22, 2016 01:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benjamintanweihao/9e30879ecdcbdd9a8b49662b3ed60fcd to your computer and use it in GitHub Desktop.
Save benjamintanweihao/9e30879ecdcbdd9a8b49662b3ed60fcd to your computer and use it in GitHub Desktop.
Mocking in Golang
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