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/mock/action_mock.go b/internal/auth0/mock/action_mock.go new file mode 100644 index 000000000..5c40d7455 --- /dev/null +++ b/internal/auth0/mock/action_mock.go @@ -0,0 +1,170 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: action.go + +// Package mock is a generated GoMock package. +package mock + +import ( + reflect "reflect" + + management "github.com/auth0/go-auth0/management" + gomock "github.com/golang/mock/gomock" +) + +// MockActionAPI is a mock of ActionAPI interface. +type MockActionAPI struct { + ctrl *gomock.Controller + recorder *MockActionAPIMockRecorder +} + +// MockActionAPIMockRecorder is the mock recorder for MockActionAPI. +type MockActionAPIMockRecorder struct { + mock *MockActionAPI +} + +// NewMockActionAPI creates a new mock instance. +func NewMockActionAPI(ctrl *gomock.Controller) *MockActionAPI { + mock := &MockActionAPI{ctrl: ctrl} + mock.recorder = &MockActionAPIMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockActionAPI) EXPECT() *MockActionAPIMockRecorder { + return m.recorder +} + +// Create mocks base method. +func (m *MockActionAPI) Create(a *management.Action, opts ...management.RequestOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{a} + for _, a_2 := range opts { + varargs = append(varargs, a_2) + } + ret := m.ctrl.Call(m, "Create", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// Create indicates an expected call of Create. +func (mr *MockActionAPIMockRecorder) Create(a interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{a}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockActionAPI)(nil).Create), varargs...) +} + +// Delete mocks base method. +func (m *MockActionAPI) Delete(id string, opts ...management.RequestOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{id} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Delete", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// Delete indicates an expected call of Delete. +func (mr *MockActionAPIMockRecorder) Delete(id interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{id}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockActionAPI)(nil).Delete), varargs...) +} + +// Deploy mocks base method. +func (m *MockActionAPI) Deploy(id string, opts ...management.RequestOption) (*management.ActionVersion, error) { + m.ctrl.T.Helper() + varargs := []interface{}{id} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Deploy", varargs...) + ret0, _ := ret[0].(*management.ActionVersion) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Deploy indicates an expected call of Deploy. +func (mr *MockActionAPIMockRecorder) Deploy(id interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{id}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Deploy", reflect.TypeOf((*MockActionAPI)(nil).Deploy), varargs...) +} + +// List mocks base method. +func (m *MockActionAPI) List(opts ...management.RequestOption) (*management.ActionList, error) { + m.ctrl.T.Helper() + varargs := []interface{}{} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "List", varargs...) + ret0, _ := ret[0].(*management.ActionList) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// List indicates an expected call of List. +func (mr *MockActionAPIMockRecorder) List(opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockActionAPI)(nil).List), opts...) +} + +// Read mocks base method. +func (m *MockActionAPI) Read(id string, opts ...management.RequestOption) (*management.Action, error) { + m.ctrl.T.Helper() + varargs := []interface{}{id} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Read", varargs...) + ret0, _ := ret[0].(*management.Action) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Read indicates an expected call of Read. +func (mr *MockActionAPIMockRecorder) Read(id interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{id}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Read", reflect.TypeOf((*MockActionAPI)(nil).Read), varargs...) +} + +// Triggers mocks base method. +func (m *MockActionAPI) Triggers(opts ...management.RequestOption) (*management.ActionTriggerList, error) { + m.ctrl.T.Helper() + varargs := []interface{}{} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Triggers", varargs...) + ret0, _ := ret[0].(*management.ActionTriggerList) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Triggers indicates an expected call of Triggers. +func (mr *MockActionAPIMockRecorder) Triggers(opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Triggers", reflect.TypeOf((*MockActionAPI)(nil).Triggers), opts...) +} + +// Update mocks base method. +func (m *MockActionAPI) Update(id string, a *management.Action, opts ...management.RequestOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{id, a} + for _, a_2 := range opts { + varargs = append(varargs, a_2) + } + ret := m.ctrl.Call(m, "Update", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// Update indicates an expected call of Update. +func (mr *MockActionAPIMockRecorder) Update(id, a interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{id, a}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockActionAPI)(nil).Update), varargs...) +} 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)