From fe942407a768ffc7d1caaf15567688d8fdee46f2 Mon Sep 17 00:00:00 2001 From: Sergiu Ghitea <28300158+sergiught@users.noreply.github.com> Date: Thu, 16 Mar 2023 20:43:15 +0100 Subject: [PATCH] Move mocks to mock pkg --- Makefile | 2 +- internal/auth0/action.go | 2 +- internal/auth0/branding_prompt.go | 2 +- internal/auth0/client.go | 2 +- internal/auth0/log.go | 4 ++-- internal/auth0/{ => mock}/action_mock.go | 4 ++-- internal/auth0/{ => mock}/branding_prompt_mock.go | 4 ++-- internal/auth0/{ => mock}/client_mock.go | 4 ++-- internal/auth0/{ => mock}/log_mock.go | 4 ++-- internal/auth0/{ => mock}/resource_server_mock.go | 4 ++-- internal/auth0/{ => mock}/rule_mock.go | 4 ++-- internal/auth0/resource_server.go | 2 +- internal/auth0/rule.go | 2 +- internal/cli/actions_test.go | 7 ++++--- internal/cli/apps_test.go | 3 ++- internal/cli/prompts_custom_text_test.go | 3 ++- 16 files changed, 28 insertions(+), 25 deletions(-) rename internal/auth0/{ => mock}/action_mock.go (98%) rename internal/auth0/{ => mock}/branding_prompt_mock.go (98%) rename internal/auth0/{ => mock}/client_mock.go (98%) rename internal/auth0/{ => mock}/log_mock.go (97%) rename internal/auth0/{ => mock}/resource_server_mock.go (98%) rename internal/auth0/{ => mock}/rule_mock.go (98%) diff --git a/Makefile b/Makefile index c7d1c636c..31dfb60f8 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/internal/auth0/action.go b/internal/auth0/action.go index 2264f65c6..3c0fd8d87 100644 --- a/internal/auth0/action.go +++ b/internal/auth0/action.go @@ -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 diff --git a/internal/auth0/branding_prompt.go b/internal/auth0/branding_prompt.go index d0936d5f6..16caabf9d 100644 --- a/internal/auth0/branding_prompt.go +++ b/internal/auth0/branding_prompt.go @@ -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 diff --git a/internal/auth0/client.go b/internal/auth0/client.go index d20801a74..1375375cf 100644 --- a/internal/auth0/client.go +++ b/internal/auth0/client.go @@ -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 diff --git a/internal/auth0/log.go b/internal/auth0/log.go index 222d2b8e8..8b7e6d788 100644 --- a/internal/auth0/log.go +++ b/internal/auth0/log.go @@ -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) diff --git a/internal/auth0/action_mock.go b/internal/auth0/mock/action_mock.go similarity index 98% rename from internal/auth0/action_mock.go rename to internal/auth0/mock/action_mock.go index 52b9597d0..5c40d7455 100644 --- a/internal/auth0/action_mock.go +++ b/internal/auth0/mock/action_mock.go @@ -1,8 +1,8 @@ // Code generated by MockGen. DO NOT EDIT. // Source: action.go -// Package auth0 is a generated GoMock package. -package auth0 +// Package mock is a generated GoMock package. +package mock import ( reflect "reflect" diff --git a/internal/auth0/branding_prompt_mock.go b/internal/auth0/mock/branding_prompt_mock.go similarity index 98% rename from internal/auth0/branding_prompt_mock.go rename to internal/auth0/mock/branding_prompt_mock.go index 21212e432..e19c5d5bc 100644 --- a/internal/auth0/branding_prompt_mock.go +++ b/internal/auth0/mock/branding_prompt_mock.go @@ -1,8 +1,8 @@ // Code generated by MockGen. DO NOT EDIT. // Source: branding_prompt.go -// Package auth0 is a generated GoMock package. -package auth0 +// Package mock is a generated GoMock package. +package mock import ( reflect "reflect" diff --git a/internal/auth0/client_mock.go b/internal/auth0/mock/client_mock.go similarity index 98% rename from internal/auth0/client_mock.go rename to internal/auth0/mock/client_mock.go index 3c4eeb861..39c882bfc 100644 --- a/internal/auth0/client_mock.go +++ b/internal/auth0/mock/client_mock.go @@ -1,8 +1,8 @@ // Code generated by MockGen. DO NOT EDIT. // Source: client.go -// Package auth0 is a generated GoMock package. -package auth0 +// Package mock is a generated GoMock package. +package mock import ( reflect "reflect" diff --git a/internal/auth0/log_mock.go b/internal/auth0/mock/log_mock.go similarity index 97% rename from internal/auth0/log_mock.go rename to internal/auth0/mock/log_mock.go index 723823356..686051198 100644 --- a/internal/auth0/log_mock.go +++ b/internal/auth0/mock/log_mock.go @@ -1,8 +1,8 @@ // Code generated by MockGen. DO NOT EDIT. // Source: log.go -// Package auth0 is a generated GoMock package. -package auth0 +// Package mock is a generated GoMock package. +package mock import ( reflect "reflect" diff --git a/internal/auth0/resource_server_mock.go b/internal/auth0/mock/resource_server_mock.go similarity index 98% rename from internal/auth0/resource_server_mock.go rename to internal/auth0/mock/resource_server_mock.go index 4a74a8573..47fbccb29 100644 --- a/internal/auth0/resource_server_mock.go +++ b/internal/auth0/mock/resource_server_mock.go @@ -1,8 +1,8 @@ // Code generated by MockGen. DO NOT EDIT. // Source: resource_server.go -// Package auth0 is a generated GoMock package. -package auth0 +// Package mock is a generated GoMock package. +package mock import ( reflect "reflect" diff --git a/internal/auth0/rule_mock.go b/internal/auth0/mock/rule_mock.go similarity index 98% rename from internal/auth0/rule_mock.go rename to internal/auth0/mock/rule_mock.go index 05359d63a..0ec6a4afe 100644 --- a/internal/auth0/rule_mock.go +++ b/internal/auth0/mock/rule_mock.go @@ -1,8 +1,8 @@ // Code generated by MockGen. DO NOT EDIT. // Source: rule.go -// Package auth0 is a generated GoMock package. -package auth0 +// Package mock is a generated GoMock package. +package mock import ( reflect "reflect" diff --git a/internal/auth0/resource_server.go b/internal/auth0/resource_server.go index 246284944..013e73db5 100644 --- a/internal/auth0/resource_server.go +++ b/internal/auth0/resource_server.go @@ -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 diff --git a/internal/auth0/rule.go b/internal/auth0/rule.go index 135cc19a0..a298c9eeb 100644 --- a/internal/auth0/rule.go +++ b/internal/auth0/rule.go @@ -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 diff --git a/internal/cli/actions_test.go b/internal/cli/actions_test.go index 52fb623bb..c9a4017c7 100644 --- a/internal/cli/actions_test.go +++ b/internal/cli/actions_test.go @@ -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" ) @@ -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) @@ -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")) @@ -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) diff --git a/internal/cli/apps_test.go b/internal/cli/apps_test.go index 2fd059f30..b82188b08 100644 --- a/internal/cli/apps_test.go +++ b/internal/cli/apps_test.go @@ -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" ) @@ -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{ diff --git a/internal/cli/prompts_custom_text_test.go b/internal/cli/prompts_custom_text_test.go index 7e3734df4..5dbef26c3 100644 --- a/internal/cli/prompts_custom_text_test.go +++ b/internal/cli/prompts_custom_text_test.go @@ -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" ) @@ -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)