-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SlackWraper mocks, update slack_client_test.go
- Loading branch information
1 parent
e1d059e
commit 1b67e1d
Showing
4 changed files
with
361 additions
and
66 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
// Automatically generated by pegomock. DO NOT EDIT! | ||
// Source: github.com/hootsuite/atlantis/server/events/webhooks (interfaces: SlackWrapper) | ||
|
||
package mocks | ||
|
||
import ( | ||
slack "github.com/nlopes/slack" | ||
pegomock "github.com/petergtz/pegomock" | ||
"reflect" | ||
) | ||
|
||
type MockSlackWrapper struct { | ||
fail func(message string, callerSkip ...int) | ||
} | ||
|
||
func NewMockSlackWrapper() *MockSlackWrapper { | ||
return &MockSlackWrapper{fail: pegomock.GlobalFailHandler} | ||
} | ||
|
||
func (mock *MockSlackWrapper) AuthTest() (*slack.AuthTestResponse, error) { | ||
params := []pegomock.Param{} | ||
result := pegomock.GetGenericMockFrom(mock).Invoke("AuthTest", params, []reflect.Type{reflect.TypeOf((**slack.AuthTestResponse)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()}) | ||
var ret0 *slack.AuthTestResponse | ||
var ret1 error | ||
if len(result) != 0 { | ||
if result[0] != nil { | ||
ret0 = result[0].(*slack.AuthTestResponse) | ||
} | ||
if result[1] != nil { | ||
ret1 = result[1].(error) | ||
} | ||
} | ||
return ret0, ret1 | ||
} | ||
|
||
func (mock *MockSlackWrapper) GetChannels(excludeArchived bool) ([]slack.Channel, error) { | ||
params := []pegomock.Param{excludeArchived} | ||
result := pegomock.GetGenericMockFrom(mock).Invoke("GetChannels", params, []reflect.Type{reflect.TypeOf((*[]slack.Channel)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()}) | ||
var ret0 []slack.Channel | ||
var ret1 error | ||
if len(result) != 0 { | ||
if result[0] != nil { | ||
ret0 = result[0].([]slack.Channel) | ||
} | ||
if result[1] != nil { | ||
ret1 = result[1].(error) | ||
} | ||
} | ||
return ret0, ret1 | ||
} | ||
|
||
func (mock *MockSlackWrapper) PostMessage(channel string, text string, parameters slack.PostMessageParameters) (string, string, error) { | ||
params := []pegomock.Param{channel, text, parameters} | ||
result := pegomock.GetGenericMockFrom(mock).Invoke("PostMessage", params, []reflect.Type{reflect.TypeOf((*string)(nil)).Elem(), reflect.TypeOf((*string)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()}) | ||
var ret0 string | ||
var ret1 string | ||
var ret2 error | ||
if len(result) != 0 { | ||
if result[0] != nil { | ||
ret0 = result[0].(string) | ||
} | ||
if result[1] != nil { | ||
ret1 = result[1].(string) | ||
} | ||
if result[2] != nil { | ||
ret2 = result[2].(error) | ||
} | ||
} | ||
return ret0, ret1, ret2 | ||
} | ||
|
||
func (mock *MockSlackWrapper) VerifyWasCalledOnce() *VerifierSlackWrapper { | ||
return &VerifierSlackWrapper{mock, pegomock.Times(1), nil} | ||
} | ||
|
||
func (mock *MockSlackWrapper) VerifyWasCalled(invocationCountMatcher pegomock.Matcher) *VerifierSlackWrapper { | ||
return &VerifierSlackWrapper{mock, invocationCountMatcher, nil} | ||
} | ||
|
||
func (mock *MockSlackWrapper) VerifyWasCalledInOrder(invocationCountMatcher pegomock.Matcher, inOrderContext *pegomock.InOrderContext) *VerifierSlackWrapper { | ||
return &VerifierSlackWrapper{mock, invocationCountMatcher, inOrderContext} | ||
} | ||
|
||
type VerifierSlackWrapper struct { | ||
mock *MockSlackWrapper | ||
invocationCountMatcher pegomock.Matcher | ||
inOrderContext *pegomock.InOrderContext | ||
} | ||
|
||
func (verifier *VerifierSlackWrapper) AuthTest() *SlackWrapper_AuthTest_OngoingVerification { | ||
params := []pegomock.Param{} | ||
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "AuthTest", params) | ||
return &SlackWrapper_AuthTest_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} | ||
} | ||
|
||
type SlackWrapper_AuthTest_OngoingVerification struct { | ||
mock *MockSlackWrapper | ||
methodInvocations []pegomock.MethodInvocation | ||
} | ||
|
||
func (c *SlackWrapper_AuthTest_OngoingVerification) GetCapturedArguments() { | ||
} | ||
|
||
func (c *SlackWrapper_AuthTest_OngoingVerification) GetAllCapturedArguments() { | ||
} | ||
|
||
func (verifier *VerifierSlackWrapper) GetChannels(excludeArchived bool) *SlackWrapper_GetChannels_OngoingVerification { | ||
params := []pegomock.Param{excludeArchived} | ||
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "GetChannels", params) | ||
return &SlackWrapper_GetChannels_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} | ||
} | ||
|
||
type SlackWrapper_GetChannels_OngoingVerification struct { | ||
mock *MockSlackWrapper | ||
methodInvocations []pegomock.MethodInvocation | ||
} | ||
|
||
func (c *SlackWrapper_GetChannels_OngoingVerification) GetCapturedArguments() bool { | ||
excludeArchived := c.GetAllCapturedArguments() | ||
return excludeArchived[len(excludeArchived)-1] | ||
} | ||
|
||
func (c *SlackWrapper_GetChannels_OngoingVerification) GetAllCapturedArguments() (_param0 []bool) { | ||
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations) | ||
if len(params) > 0 { | ||
_param0 = make([]bool, len(params[0])) | ||
for u, param := range params[0] { | ||
_param0[u] = param.(bool) | ||
} | ||
} | ||
return | ||
} | ||
|
||
func (verifier *VerifierSlackWrapper) PostMessage(channel string, text string, parameters slack.PostMessageParameters) *SlackWrapper_PostMessage_OngoingVerification { | ||
params := []pegomock.Param{channel, text, parameters} | ||
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "PostMessage", params) | ||
return &SlackWrapper_PostMessage_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} | ||
} | ||
|
||
type SlackWrapper_PostMessage_OngoingVerification struct { | ||
mock *MockSlackWrapper | ||
methodInvocations []pegomock.MethodInvocation | ||
} | ||
|
||
func (c *SlackWrapper_PostMessage_OngoingVerification) GetCapturedArguments() (string, string, slack.PostMessageParameters) { | ||
channel, text, parameters := c.GetAllCapturedArguments() | ||
return channel[len(channel)-1], text[len(text)-1], parameters[len(parameters)-1] | ||
} | ||
|
||
func (c *SlackWrapper_PostMessage_OngoingVerification) GetAllCapturedArguments() (_param0 []string, _param1 []string, _param2 []slack.PostMessageParameters) { | ||
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations) | ||
if len(params) > 0 { | ||
_param0 = make([]string, len(params[0])) | ||
for u, param := range params[0] { | ||
_param0[u] = param.(string) | ||
} | ||
_param1 = make([]string, len(params[1])) | ||
for u, param := range params[1] { | ||
_param1[u] = param.(string) | ||
} | ||
_param2 = make([]slack.PostMessageParameters, len(params[2])) | ||
for u, param := range params[2] { | ||
_param2[u] = param.(slack.PostMessageParameters) | ||
} | ||
} | ||
return | ||
} |
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
Oops, something went wrong.