Skip to content

Commit

Permalink
Move mocks to mock pkg (#680)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiught authored Mar 17, 2023
1 parent 5fb7796 commit 200ea69
Show file tree
Hide file tree
Showing 16 changed files with 196 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
NAME := auth0-cli
GO_PKG := github.com/auth0/$(NAME)
GO_BIN ?= $(shell go env GOPATH)/bin
GO_PACKAGES := $(shell go list ./... | grep -v vendor)
GO_PACKAGES := $(shell go list ./... | grep -vE "vendor|tools|mock")

## Configuration for build-info
BUILD_DIR ?= $(CURDIR)/out
Expand Down
2 changes: 1 addition & 1 deletion internal/auth0/action.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:generate mockgen -source=action.go -destination=action_mock.go -package=auth0
//go:generate mockgen -source=action.go -destination=mock/action_mock.go -package=mock

package auth0

Expand Down
2 changes: 1 addition & 1 deletion internal/auth0/branding_prompt.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:generate mockgen -source=branding_prompt.go -destination=branding_prompt_mock.go -package=auth0
//go:generate mockgen -source=branding_prompt.go -destination=mock/branding_prompt_mock.go -package=mock

package auth0

Expand Down
2 changes: 1 addition & 1 deletion internal/auth0/client.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:generate mockgen -source=client.go -destination=client_mock.go -package=auth0
//go:generate mockgen -source=client.go -destination=mock/client_mock.go -package=mock

package auth0

Expand Down
4 changes: 2 additions & 2 deletions internal/auth0/log.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//go:generate mockgen -source=log.go -destination=log_mock.go -package=auth0
//go:generate mockgen -source=log.go -destination=mock/log_mock.go -package=mock

package auth0

import "github.com/auth0/go-auth0/management"

type LogAPI interface {
// Retrieves the data related to the log entry identified by id. This returns a
// Read the data related to the log entry identified by id. This returns a
// single log entry representation as specified in the schema.
Read(id string, opts ...management.RequestOption) (l *management.Log, err error)

Expand Down
170 changes: 170 additions & 0 deletions internal/auth0/mock/action_mock.go

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

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

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

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

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

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

2 changes: 1 addition & 1 deletion internal/auth0/resource_server.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:generate mockgen -source=resource_server.go -destination=resource_server_mock.go -package=auth0
//go:generate mockgen -source=resource_server.go -destination=mock/resource_server_mock.go -package=mock

package auth0

Expand Down
2 changes: 1 addition & 1 deletion internal/auth0/rule.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:generate mockgen -source=rule.go -destination=rule_mock.go -package=auth0
//go:generate mockgen -source=rule.go -destination=mock/rule_mock.go -package=mock

package auth0

Expand Down
7 changes: 4 additions & 3 deletions internal/cli/actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/stretchr/testify/assert"

"github.com/auth0/auth0-cli/internal/auth0"
"github.com/auth0/auth0-cli/internal/auth0/mock"
"github.com/auth0/auth0-cli/internal/display"
)

Expand All @@ -20,7 +21,7 @@ func TestActionsDeployCmd(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

actionAPI := auth0.NewMockActionAPI(ctrl)
actionAPI := mock.NewMockActionAPI(ctrl)
actionAPI.EXPECT().
Deploy(actionID).
Return(nil, nil)
Expand Down Expand Up @@ -77,7 +78,7 @@ func TestActionsDeployCmd(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

actionAPI := auth0.NewMockActionAPI(ctrl)
actionAPI := mock.NewMockActionAPI(ctrl)
actionAPI.EXPECT().
Deploy(actionID).
Return(nil, fmt.Errorf("400 Bad Request"))
Expand All @@ -103,7 +104,7 @@ func TestActionsDeployCmd(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

actionAPI := auth0.NewMockActionAPI(ctrl)
actionAPI := mock.NewMockActionAPI(ctrl)
actionAPI.EXPECT().
Deploy(actionID).
Return(nil, nil)
Expand Down
3 changes: 2 additions & 1 deletion internal/cli/apps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/golang/mock/gomock"

"github.com/auth0/auth0-cli/internal/auth0"
"github.com/auth0/auth0-cli/internal/auth0/mock"
"github.com/auth0/auth0-cli/internal/display"
)

Expand Down Expand Up @@ -50,7 +51,7 @@ func TestAppsListCmd(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

clientAPI := auth0.NewMockClientAPI(ctrl)
clientAPI := mock.NewMockClientAPI(ctrl)
clientAPI.EXPECT().
List(gomock.Any()).
Return(&management.ClientList{
Expand Down
3 changes: 2 additions & 1 deletion internal/cli/prompts_custom_text_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/stretchr/testify/assert"

"github.com/auth0/auth0-cli/internal/auth0"
"github.com/auth0/auth0-cli/internal/auth0/mock"
"github.com/auth0/auth0-cli/internal/display"
)

Expand Down Expand Up @@ -54,7 +55,7 @@ func TestBrandingTextsShowCmd(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

brandingTextsAPI := auth0.NewMockPromptAPI(ctrl)
brandingTextsAPI := mock.NewMockPromptAPI(ctrl)
brandingTextsAPI.EXPECT().
CustomText(test.inputPrompt, test.inputLanguage).
Return(test.returnedCustomText, test.returnedError)
Expand Down

0 comments on commit 200ea69

Please sign in to comment.