Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
Fix mocks
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Dye <[email protected]>
  • Loading branch information
andrewwdye committed Mar 3, 2023
1 parent aee4a77 commit 10a894c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
35 changes: 19 additions & 16 deletions clients/go/admin/mocks/TokenSource.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions clients/go/admin/token_source_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ import (
"github.com/flyteorg/flytestdlib/logger"
)

//go:generate mockery -name TokenSource
type TokenSource interface {
Token() (*oauth2.Token, error)
}

const (
audienceKey = "audience"
)
Expand Down
6 changes: 2 additions & 4 deletions clients/go/admin/token_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import (
"github.com/flyteorg/flytestdlib/config"
)

//go:generate mockery --srcpkg golang.org/x/oauth2 --name TokenSource

type DummyTestTokenSource struct {
oauth2.TokenSource
}
Expand Down Expand Up @@ -257,9 +255,9 @@ func TestCustomTokenSource_Token(t *testing.T) {

mockSource := &adminMocks.TokenSource{}
if test.newToken != nil {
mockSource.On("Token").Return(test.newToken, nil)
mockSource.OnToken().Return(test.newToken, nil)
} else {
mockSource.On("Token").Return(nil, fmt.Errorf("refresh token failed"))
mockSource.OnToken().Return(nil, fmt.Errorf("refresh token failed"))
}
customSource.new = mockSource
customSource.refreshTime = test.refreshTime
Expand Down

0 comments on commit 10a894c

Please sign in to comment.