auth yay!
This commit is contained in:
parent
a3a1654030
commit
c50bfc1a7f
9 changed files with 339 additions and 110 deletions
|
@ -46,7 +46,7 @@ func (c *DiscordClientMock) ClientAuth(req *http.Request, accessToken string) {
|
|||
c.Called(req, accessToken)
|
||||
}
|
||||
|
||||
func (c *DiscordClientMock) MockResponse(method, path string, statusCode int, data any) {
|
||||
func (c *DiscordClientMock) MockResponse(method, path string, statusCode int, data any) *mock.Call {
|
||||
body := bytes.Buffer{}
|
||||
json.NewEncoder(&body).Encode(data)
|
||||
|
||||
|
@ -57,7 +57,7 @@ func (c *DiscordClientMock) MockResponse(method, path string, statusCode int, da
|
|||
|
||||
pathMatcher := regexp.MustCompile(strings.ReplaceAll(path, "*", "[a-z0-9_-]+"))
|
||||
|
||||
c.On("Do", mock.MatchedBy(func(req *http.Request) bool {
|
||||
return c.On("Do", mock.MatchedBy(func(req *http.Request) bool {
|
||||
return req.Method == method && pathMatcher.MatchString(req.URL.Path)
|
||||
})).Return(r, nil)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue