From de91741f852a0cc634683108cb7439a91c905ccc Mon Sep 17 00:00:00 2001 From: Dave Shoup Date: Thu, 20 Aug 2026 17:05:23 -0400 Subject: [PATCH 1/2] migrate test mocks from travisjeffery/mocker to go.uber.org/mock The go-generate pre-commit hook could not pass: mocker (unmaintained since 2020) fails against the repo's current golang.org/x/tools, so `go generate` errored and contributors bypassed the hook with --no-verify. Finish the migration the repo already started (Flink was on mockgen) rather than pin a dead tool. - Convert the 10 mocker //go:generate directives to `go run go.uber.org/mock/ mockgen` reflect mode; regenerate the auth/io/form/local mocks. - Rewrite the mocker struct-of-func-field call sites to gomock EXPECT() across 7 test files; migrate the mock/client.go helper. - Normalize the 13 Flink directives to `go run` (no PATH-installed mockgen) and regenerate; pin go.uber.org/mock v0.4.0 -> v0.5.2 so generation is reproducible and the hook passes. - Delete the dead PassThroughFileSystem helper and the orphaned launch_darkly directive. travisjeffery/mocker remains an indirect dependency (transitively required by cmf-sdk-go and ccloud-sdk-go-v1-public); no first-party usage remains. Co-Authored-By: Claude Opus 4.8 (1M context) --- go.mod | 2 +- go.sum | 4 +- internal/local/command_services_test.go | 134 +- internal/login/command_test.go | 450 +++---- internal/logout/command_test.go | 34 +- mock/auth_mds_client.go | 122 +- mock/auth_token_handler.go | 248 ++-- mock/ccloud_client_factory.go | 182 ++- mock/client.go | 43 +- mock/confluent_current.go | 1098 ++++++++--------- mock/confluent_home.go | 871 ++++++------- mock/login_credentials_manager.go | 865 ++++++------- mock/login_organization_manager.go | 238 ++-- pkg/auth/auth_token_handler.go | 2 +- pkg/auth/ccloud_client_factory.go | 2 +- pkg/auth/login_credentials_manager.go | 2 +- pkg/auth/login_credentials_manager_test.go | 15 +- pkg/auth/login_organization_manager.go | 2 +- pkg/auth/mds_client.go | 2 +- pkg/cmd/prerunner_test.go | 364 +++--- pkg/featureflags/feature_flags.go | 2 - .../test/mock/application_controller_mock.go | 1 + pkg/flink/test/mock/cmf_client_mock.go | 6 +- pkg/flink/test/mock/console_parser_mock.go | 1 + pkg/flink/test/mock/gateway_client_mock.go | 97 +- pkg/flink/test/mock/input_controller_mock.go | 17 +- pkg/flink/test/mock/json_rpc2_conn.go | 47 +- pkg/flink/test/mock/mock_generator.go | 27 +- pkg/flink/test/mock/output_controller_mock.go | 1 + pkg/flink/test/mock/prompt_mock.go | 9 +- pkg/flink/test/mock/result_fetcher_mock.go | 9 +- pkg/flink/test/mock/reverse_i_search_mock.go | 9 +- .../test/mock/statement_controller_mock.go | 9 +- pkg/flink/test/mock/store_mock.go | 2 +- pkg/flink/test/mock/table_view_mock.go | 9 +- pkg/form/field_test.go | 17 +- pkg/form/form_test.go | 13 +- pkg/form/prompt.go | 2 +- pkg/io/io.go | 2 +- pkg/local/confluent_current.go | 2 +- pkg/local/confluent_home.go | 2 +- pkg/mock/filesystem.go | 1029 +++++++-------- pkg/mock/filesystem_pt.go | 116 -- pkg/mock/prompt.go | 228 ++-- 44 files changed, 2854 insertions(+), 3483 deletions(-) delete mode 100644 pkg/mock/filesystem_pt.go diff --git a/go.mod b/go.mod index df7a2a5058..d25136e5c9 100644 --- a/go.mod +++ b/go.mod @@ -114,7 +114,7 @@ require ( go.opentelemetry.io/otel/metric v1.44.0 go.opentelemetry.io/otel/sdk v1.43.0 go.opentelemetry.io/otel/sdk/metric v1.43.0 - go.uber.org/mock v0.4.0 + go.uber.org/mock v0.5.2 golang.org/x/crypto v0.55.0 golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f golang.org/x/oauth2 v0.36.0 diff --git a/go.sum b/go.sum index 22ecac73dc..42636e14b4 100644 --- a/go.sum +++ b/go.sum @@ -726,8 +726,8 @@ go.opentelemetry.io/otel/trace v1.44.0 h1:jxF5CsGYCe74MCRx2X4g7WsY/VBKRqqpNvXlX/ go.opentelemetry.io/otel/trace v1.44.0/go.mod h1:oLl1jrMQAVo6v3GAggN+1VH9VIz9iUSvW53sW1Q8PIE= go.opentelemetry.io/proto/otlp v1.10.0 h1:IQRWgT5srOCYfiWnpqUYz9CVmbO8bFmKcwYxpuCSL2g= go.opentelemetry.io/proto/otlp v1.10.0/go.mod h1:/CV4QoCR/S9yaPj8utp3lvQPoqMtxXdzn7ozvvozVqk= -go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= -go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= +go.uber.org/mock v0.5.2 h1:LbtPTcP8A5k9WPXj54PPPbjcI4Y6lhyOZXn+VS7wNko= +go.uber.org/mock v0.5.2/go.mod h1:wLlUxC2vVTPTaE3UD51E0BGOAElKrILxhVSDYQLld5o= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= diff --git a/internal/local/command_services_test.go b/internal/local/command_services_test.go index 1de66913a4..d72b60e4df 100644 --- a/internal/local/command_services_test.go +++ b/internal/local/command_services_test.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/stretchr/testify/require" + "go.uber.org/mock/gomock" climock "github.com/confluentinc/cli/v4/mock" ) @@ -245,29 +246,20 @@ func getConfigForVersion(t *testing.T, service, version string) map[string]strin t.Helper() req := require.New(t) + ctrl := gomock.NewController(t) + ch := climock.NewMockConfluentHome(ctrl) + ch.EXPECT().IsConfluentPlatform().Return(true, nil).AnyTimes() + ch.EXPECT().GetConfluentVersion().Return(version, nil).AnyTimes() + ch.EXPECT().GetFile(gomock.Any()).Return(exampleFile, nil).AnyTimes() + ch.EXPECT().FindFile(gomock.Any()).Return([]string{exampleFile}, nil).AnyTimes() + ch.EXPECT().ReadServiceConfig(gomock.Any(), gomock.Any()).Return([]byte("plugin.path=share/java"), nil).AnyTimes() + + cc := climock.NewMockConfluentCurrent(ctrl) + cc.EXPECT().GetDataDir(gomock.Any()).Return(exampleDir, nil).AnyTimes() + c := &command{ - ch: &climock.MockConfluentHome{ - IsConfluentPlatformFunc: func() (bool, error) { - return true, nil - }, - GetConfluentVersionFunc: func() (string, error) { - return version, nil - }, - GetFileFunc: func(path ...string) (string, error) { - return exampleFile, nil - }, - FindFileFunc: func(pattern string) ([]string, error) { - return []string{exampleFile}, nil - }, - ReadServiceConfigFunc: func(service string, _ bool) ([]byte, error) { - return []byte("plugin.path=share/java"), nil - }, - }, - cc: &climock.MockConfluentCurrent{ - GetDataDirFunc: func(service string) (string, error) { - return exampleDir, nil - }, - }, + ch: ch, + cc: cc, } got, err := c.getConfig(service) @@ -305,29 +297,20 @@ func TestGetZookeeperConfig(t *testing.T) { func testGetConfig(t *testing.T, service string, want map[string]string) { req := require.New(t) + ctrl := gomock.NewController(t) + ch := climock.NewMockConfluentHome(ctrl) + ch.EXPECT().IsConfluentPlatform().Return(true, nil).AnyTimes() + ch.EXPECT().GetConfluentVersion().Return("7.9.0", nil).AnyTimes() + ch.EXPECT().GetFile(gomock.Any()).Return(exampleFile, nil).AnyTimes() + ch.EXPECT().FindFile(gomock.Any()).Return([]string{exampleFile}, nil).AnyTimes() + ch.EXPECT().ReadServiceConfig(gomock.Any(), gomock.Any()).Return([]byte("plugin.path=share/java"), nil).AnyTimes() + + cc := climock.NewMockConfluentCurrent(ctrl) + cc.EXPECT().GetDataDir(gomock.Any()).Return(exampleDir, nil).AnyTimes() + c := &command{ - ch: &climock.MockConfluentHome{ - IsConfluentPlatformFunc: func() (bool, error) { - return true, nil - }, - GetConfluentVersionFunc: func() (string, error) { - return "7.9.0", nil - }, - GetFileFunc: func(path ...string) (string, error) { - return exampleFile, nil - }, - FindFileFunc: func(pattern string) ([]string, error) { - return []string{exampleFile}, nil - }, - ReadServiceConfigFunc: func(service string, _ bool) ([]byte, error) { - return []byte("plugin.path=share/java"), nil - }, - }, - cc: &climock.MockConfluentCurrent{ - GetDataDirFunc: func(service string) (string, error) { - return exampleDir, nil - }, - }, + ch: ch, + cc: cc, } got, err := c.getConfig(service) @@ -339,29 +322,20 @@ func testGetConfig(t *testing.T, service string, want map[string]string) { func testGetConfigC3(t *testing.T, service string, want map[string]string) { req := require.New(t) + ctrl := gomock.NewController(t) + ch := climock.NewMockConfluentHome(ctrl) + ch.EXPECT().IsConfluentPlatform().Return(true, nil).AnyTimes() + ch.EXPECT().GetConfluentVersion().Return("8.1.0", nil).AnyTimes() + ch.EXPECT().GetFile(gomock.Any()).Return(exampleFile, nil).AnyTimes() + ch.EXPECT().FindFile(gomock.Any()).Return([]string{exampleFile}, nil).AnyTimes() + ch.EXPECT().ReadServiceConfig(gomock.Any(), gomock.Any()).Return([]byte("plugin.path=share/java"), nil).AnyTimes() + + cc := climock.NewMockConfluentCurrent(ctrl) + cc.EXPECT().GetDataDir(gomock.Any()).Return(exampleDir, nil).AnyTimes() + c := &command{ - ch: &climock.MockConfluentHome{ - IsConfluentPlatformFunc: func() (bool, error) { - return true, nil - }, - GetConfluentVersionFunc: func() (string, error) { - return "8.1.0", nil - }, - GetFileFunc: func(path ...string) (string, error) { - return exampleFile, nil - }, - FindFileFunc: func(pattern string) ([]string, error) { - return []string{exampleFile}, nil - }, - ReadServiceConfigFunc: func(service string, _ bool) ([]byte, error) { - return []byte("plugin.path=share/java"), nil - }, - }, - cc: &climock.MockConfluentCurrent{ - GetDataDirFunc: func(service string) (string, error) { - return exampleDir, nil - }, - }, + ch: ch, + cc: cc, } got, err := c.getConfig(service) @@ -373,15 +347,13 @@ func testGetConfigC3(t *testing.T, service string, want map[string]string) { func TestConfluentPlatformAvailableServices(t *testing.T) { req := require.New(t) + ctrl := gomock.NewController(t) + ch := climock.NewMockConfluentHome(ctrl) + ch.EXPECT().IsConfluentPlatform().Return(true, nil).AnyTimes() + ch.EXPECT().GetConfluentVersion().Return("7.9.0", nil).AnyTimes() + c := &command{ - ch: &climock.MockConfluentHome{ - IsConfluentPlatformFunc: func() (bool, error) { - return true, nil - }, - GetConfluentVersionFunc: func() (string, error) { - return "7.9.0", nil - }, - }, + ch: ch, } got, err := c.getAvailableServices() @@ -402,15 +374,13 @@ func TestConfluentPlatformAvailableServices(t *testing.T) { func TestConfluentCommunitySoftwareAvailableServices(t *testing.T) { req := require.New(t) + ctrl := gomock.NewController(t) + ch := climock.NewMockConfluentHome(ctrl) + ch.EXPECT().IsConfluentPlatform().Return(false, nil).AnyTimes() + ch.EXPECT().GetConfluentVersion().Return("7.9.0", nil).AnyTimes() + c := &command{ - ch: &climock.MockConfluentHome{ - IsConfluentPlatformFunc: func() (bool, error) { - return false, nil - }, - GetConfluentVersionFunc: func() (string, error) { - return "7.9.0", nil - }, - }, + ch: ch, } got, err := c.getAvailableServices() diff --git a/internal/login/command_test.go b/internal/login/command_test.go index d57c7c3c3e..826c2ae7d6 100644 --- a/internal/login/command_test.go +++ b/internal/login/command_test.go @@ -19,6 +19,7 @@ import ( "github.com/spf13/cobra" "github.com/stretchr/testify/require" + "go.uber.org/mock/gomock" ccloudv1 "github.com/confluentinc/ccloud-sdk-go-v1-public" ccloudv1mock "github.com/confluentinc/ccloud-sdk-go-v1-public/mock" @@ -61,87 +62,77 @@ var ( }, nil }, } - mockUserInterface = &ccloudv1mock.UserInterface{} - mockLoginCredentialsManager = &climock.LoginCredentialsManager{ - GetCloudCredentialsFromEnvVarFunc: func(_ string) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - GetCloudCredentialsFromPromptFunc: func(_ string) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return &pauth.Credentials{ - Username: promptUser, - Password: promptPassword, - }, nil - } - }, - GetOnPremCredentialsFromEnvVarFunc: func() func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - GetOnPremCredentialsFromPromptFunc: func() func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return &pauth.Credentials{ - Username: promptUser, - Password: promptPassword, - }, nil - } - }, - GetCredentialsFromConfigFunc: func(_ *config.Config, _ config.MachineParams) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - GetOnPremSsoCredentialsFunc: func(_, _, _, _ string, _ bool) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - GetOnPremSsoCredentialsFromConfigFunc: func(_ *config.Config, _ bool) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - GetCredentialsFromKeychainFunc: func(_ bool, _, _ string) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - SetCloudClientFunc: func(_ *ccloudv1.Client) {}, - } - LoginOrganizationManager = &climock.LoginOrganizationManager{ - GetLoginOrganizationFromFlagFunc: func(cmd *cobra.Command) func() string { - return pauth.NewLoginOrganizationManagerImpl().GetLoginOrganizationFromFlag(cmd) - }, - GetLoginOrganizationFromEnvironmentVariableFunc: func() func() string { - return pauth.NewLoginOrganizationManagerImpl().GetLoginOrganizationFromEnvironmentVariable() - }, - } - AuthTokenHandler = &climock.AuthTokenHandler{ - GetCCloudTokensFunc: func(_ pauth.CCloudClientFactory, _ string, credentials *pauth.Credentials, noBrowser bool, organizationId string) (string, string, error) { - if organizationId == "" || organizationId == organizationId1 { - return testToken1, refreshToken, nil - } else if organizationId == organizationId2 { - return testToken2, refreshToken, nil - } else { - return "", "", &ccloudv1.Error{Message: "invalid user", Code: http.StatusUnauthorized} - } - }, - GetConfluentTokenFunc: func(_ *mdsv1.APIClient, _ *pauth.Credentials, _ bool) (string, string, error) { - return testToken1, "", nil - }, - } - mockAuthResponse = mdsv1.AuthenticationResponse{ + mockUserInterface = &ccloudv1mock.UserInterface{} + mockAuthResponse = mdsv1.AuthenticationResponse{ AuthToken: testToken1, TokenType: "JWT", ExpiresIn: 100, } ) +func newTestLoginCredentialsManager(ctrl *gomock.Controller) *climock.MockLoginCredentialsManager { + m := climock.NewMockLoginCredentialsManager(ctrl) + m.EXPECT().GetCloudCredentialsFromEnvVar(gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + m.EXPECT().GetCloudCredentialsFromPrompt(gomock.Any()).Return(func() (*pauth.Credentials, error) { + return &pauth.Credentials{ + Username: promptUser, + Password: promptPassword, + }, nil + }).AnyTimes() + m.EXPECT().GetOnPremCredentialsFromEnvVar().Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + m.EXPECT().GetOnPremCredentialsFromPrompt().Return(func() (*pauth.Credentials, error) { + return &pauth.Credentials{ + Username: promptUser, + Password: promptPassword, + }, nil + }).AnyTimes() + m.EXPECT().GetCredentialsFromConfig(gomock.Any(), gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + m.EXPECT().GetOnPremSsoCredentials(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + m.EXPECT().GetOnPremSsoCredentialsFromConfig(gomock.Any(), gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + m.EXPECT().GetCredentialsFromKeychain(gomock.Any(), gomock.Any(), gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + m.EXPECT().SetCloudClient(gomock.Any()).AnyTimes() + return m +} + +func newTestLoginOrganizationManager(ctrl *gomock.Controller) *climock.MockLoginOrganizationManager { + m := climock.NewMockLoginOrganizationManager(ctrl) + m.EXPECT().GetLoginOrganizationFromFlag(gomock.Any()).DoAndReturn(func(cmd *cobra.Command) func() string { + return pauth.NewLoginOrganizationManagerImpl().GetLoginOrganizationFromFlag(cmd) + }).AnyTimes() + m.EXPECT().GetLoginOrganizationFromEnvironmentVariable().Return(pauth.NewLoginOrganizationManagerImpl().GetLoginOrganizationFromEnvironmentVariable()).AnyTimes() + return m +} + +func newTestAuthTokenHandler(ctrl *gomock.Controller) *climock.MockAuthTokenHandler { + m := climock.NewMockAuthTokenHandler(ctrl) + m.EXPECT().GetCCloudTokens(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(_ pauth.CCloudClientFactory, _ string, credentials *pauth.Credentials, noBrowser bool, organizationId string) (string, string, error) { + if organizationId == "" || organizationId == organizationId1 { + return testToken1, refreshToken, nil + } else if organizationId == organizationId2 { + return testToken2, refreshToken, nil + } else { + return "", "", &ccloudv1.Error{Message: "invalid user", Code: http.StatusUnauthorized} + } + }).AnyTimes() + m.EXPECT().GetConfluentToken(gomock.Any(), gomock.Any(), gomock.Any()).Return(testToken1, "", nil).AnyTimes() + return m +} + func TestCredentialsOverride(t *testing.T) { req := require.New(t) + ctrl := gomock.NewController(t) auth := &ccloudv1mock.Auth{ LoginFunc: func(_ *ccloudv1.AuthenticateRequest) (*ccloudv1.AuthenticateReply, error) { return &ccloudv1.AuthenticateReply{Token: testToken1}, nil @@ -159,30 +150,21 @@ func TestCredentialsOverride(t *testing.T) { }, } userInterface := &ccloudv1mock.UserInterface{} - mockLoginCredentialsManager := &climock.LoginCredentialsManager{ - GetCloudCredentialsFromEnvVarFunc: func(_ string) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return envCreds, nil - } - }, - GetCredentialsFromConfigFunc: func(_ *config.Config, _ config.MachineParams) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - GetCloudCredentialsFromPromptFunc: func(_ string) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - GetCredentialsFromKeychainFunc: func(_ bool, _, _ string) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - SetCloudClientFunc: func(_ *ccloudv1.Client) {}, - } - loginCmd, cfg := newLoginCmd(auth, userInterface, true, req, AuthTokenHandler, mockLoginCredentialsManager, LoginOrganizationManager) + mockLoginCredentialsManager := climock.NewMockLoginCredentialsManager(ctrl) + mockLoginCredentialsManager.EXPECT().GetCloudCredentialsFromEnvVar(gomock.Any()).Return(func() (*pauth.Credentials, error) { + return envCreds, nil + }).AnyTimes() + mockLoginCredentialsManager.EXPECT().GetCredentialsFromConfig(gomock.Any(), gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + mockLoginCredentialsManager.EXPECT().GetCloudCredentialsFromPrompt(gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + mockLoginCredentialsManager.EXPECT().GetCredentialsFromKeychain(gomock.Any(), gomock.Any(), gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + mockLoginCredentialsManager.EXPECT().SetCloudClient(gomock.Any()).AnyTimes() + loginCmd, cfg := newLoginCmd(ctrl, auth, userInterface, true, req, newTestAuthTokenHandler(ctrl), mockLoginCredentialsManager, newTestLoginOrganizationManager(ctrl)) output, err := pcmd.ExecuteCommand(loginCmd) req.NoError(err) @@ -198,6 +180,7 @@ func TestCredentialsOverride(t *testing.T) { func TestOrgIdOverride(t *testing.T) { req := require.New(t) + ctrl := gomock.NewController(t) auth := &ccloudv1mock.Auth{ UserFunc: func() (*ccloudv1.GetMeReply, error) { return &ccloudv1.GetMeReply{ @@ -213,13 +196,14 @@ func TestOrgIdOverride(t *testing.T) { } userInterface := &ccloudv1mock.UserInterface{} - loginOrganizationManager := &climock.LoginOrganizationManager{ - GetLoginOrganizationFromFlagFunc: LoginOrganizationManager.GetLoginOrganizationFromFlagFunc, - GetLoginOrganizationFromEnvironmentVariableFunc: func() func() string { - return func() string { return organizationId2 } - }, - } - loginCmd, cfg := newLoginCmd(auth, userInterface, true, req, AuthTokenHandler, mockLoginCredentialsManager, loginOrganizationManager) + loginOrganizationManager := climock.NewMockLoginOrganizationManager(ctrl) + loginOrganizationManager.EXPECT().GetLoginOrganizationFromFlag(gomock.Any()).DoAndReturn(func(cmd *cobra.Command) func() string { + return pauth.NewLoginOrganizationManagerImpl().GetLoginOrganizationFromFlag(cmd) + }).AnyTimes() + loginOrganizationManager.EXPECT().GetLoginOrganizationFromEnvironmentVariable().Return(func() string { + return organizationId2 + }).AnyTimes() + loginCmd, cfg := newLoginCmd(ctrl, auth, userInterface, true, req, newTestAuthTokenHandler(ctrl), newTestLoginCredentialsManager(ctrl), loginOrganizationManager) output, err := pcmd.ExecuteCommand(loginCmd) req.NoError(err) @@ -236,6 +220,7 @@ func TestOrgIdOverride(t *testing.T) { func TestLoginSuccess(t *testing.T) { req := require.New(t) + ctrl := gomock.NewController(t) useOrgTwo := false auth := &ccloudv1mock.Auth{ LoginFunc: func(_ *ccloudv1.AuthenticateRequest) (*ccloudv1.AuthenticateReply, error) { @@ -297,7 +282,7 @@ func TestLoginSuccess(t *testing.T) { s.args = append(s.args, "--organization", s.orgId) } - loginCmd, cfg := newLoginCmd(auth, userInterface, s.isCloud, req, AuthTokenHandler, mockLoginCredentialsManager, LoginOrganizationManager) + loginCmd, cfg := newLoginCmd(ctrl, auth, userInterface, s.isCloud, req, newTestAuthTokenHandler(ctrl), newTestLoginCredentialsManager(ctrl), newTestLoginOrganizationManager(ctrl)) output, err := pcmd.ExecuteCommand(loginCmd, s.args...) req.NoError(err) if s.isCloud { @@ -348,74 +333,53 @@ func TestLoginOrderOfPrecedence(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - loginCredentialsManager := &climock.LoginCredentialsManager{ - GetCloudCredentialsFromEnvVarFunc: func(_ string) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - GetCloudCredentialsFromPromptFunc: func(_ string) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return &pauth.Credentials{ - Username: promptUser, - Password: promptPassword, - }, nil - } - }, - GetOnPremCredentialsFromEnvVarFunc: func() func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - GetOnPremCredentialsFromPromptFunc: func() func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return &pauth.Credentials{ - Username: promptUser, - Password: promptPassword, - }, nil - } - }, - GetCredentialsFromConfigFunc: func(_ *config.Config, _ config.MachineParams) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - GetOnPremSsoCredentialsFunc: func(_, _, _, _ string, _ bool) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - GetOnPremSsoCredentialsFromConfigFunc: func(_ *config.Config, _ bool) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - GetCredentialsFromKeychainFunc: func(_ bool, _, _ string) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - SetCloudClientFunc: func(_ *ccloudv1.Client) {}, + ctrl := gomock.NewController(t) + loginCredentialsManager := climock.NewMockLoginCredentialsManager(ctrl) + if test.isCloud && test.setEnvVar { + loginCredentialsManager.EXPECT().GetCloudCredentialsFromEnvVar(gomock.Any()).Return(func() (*pauth.Credentials, error) { + return envCreds, nil + }).AnyTimes() + } else { + loginCredentialsManager.EXPECT().GetCloudCredentialsFromEnvVar(gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() } - if test.isCloud { - if test.setEnvVar { - loginCredentialsManager.GetCloudCredentialsFromEnvVarFunc = func(_ string) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return envCreds, nil - } - } - } + if !test.isCloud && test.setEnvVar { + loginCredentialsManager.EXPECT().GetOnPremCredentialsFromEnvVar().Return(func() (*pauth.Credentials, error) { + return envCreds, nil + }).AnyTimes() } else { - if test.setEnvVar { - loginCredentialsManager.GetOnPremCredentialsFromEnvVarFunc = func() func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return envCreds, nil - } - } - } + loginCredentialsManager.EXPECT().GetOnPremCredentialsFromEnvVar().Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() } + loginCredentialsManager.EXPECT().GetCloudCredentialsFromPrompt(gomock.Any()).Return(func() (*pauth.Credentials, error) { + return &pauth.Credentials{ + Username: promptUser, + Password: promptPassword, + }, nil + }).AnyTimes() + loginCredentialsManager.EXPECT().GetOnPremCredentialsFromPrompt().Return(func() (*pauth.Credentials, error) { + return &pauth.Credentials{ + Username: promptUser, + Password: promptPassword, + }, nil + }).AnyTimes() + loginCredentialsManager.EXPECT().GetCredentialsFromConfig(gomock.Any(), gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + loginCredentialsManager.EXPECT().GetOnPremSsoCredentials(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + loginCredentialsManager.EXPECT().GetOnPremSsoCredentialsFromConfig(gomock.Any(), gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + loginCredentialsManager.EXPECT().GetCredentialsFromKeychain(gomock.Any(), gomock.Any(), gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + loginCredentialsManager.EXPECT().SetCloudClient(gomock.Any()).AnyTimes() - loginCmd, _ := newLoginCmd(mockAuth, mockUserInterface, test.isCloud, req, AuthTokenHandler, loginCredentialsManager, LoginOrganizationManager) + loginCmd, _ := newLoginCmd(ctrl, mockAuth, mockUserInterface, test.isCloud, req, newTestAuthTokenHandler(ctrl), loginCredentialsManager, newTestLoginOrganizationManager(ctrl)) var loginArgs []string if !test.isCloud { loginArgs = []string{"--url", "http://localhost:8090"} @@ -437,10 +401,6 @@ func TestLoginOrderOfPrecedence(t *testing.T) { func TestPromptLoginFlag(t *testing.T) { req := require.New(t) - wrongCreds := &pauth.Credentials{ - Username: "wrong_user", - Password: "wrong_password", - } tests := []struct { name string @@ -457,36 +417,25 @@ func TestPromptLoginFlag(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - mockLoginCredentialsManager := &climock.LoginCredentialsManager{ - GetCloudCredentialsFromEnvVarFunc: func(_ string) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return wrongCreds, nil - } - }, - GetCloudCredentialsFromPromptFunc: func(_ string) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return &pauth.Credentials{ - Username: promptUser, - Password: promptPassword, - }, nil - } - }, - GetOnPremCredentialsFromEnvVarFunc: func() func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return wrongCreds, nil - } - }, - GetOnPremCredentialsFromPromptFunc: func() func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return &pauth.Credentials{ - Username: promptUser, - Password: promptPassword, - }, nil - } - }, - SetCloudClientFunc: func(_ *ccloudv1.Client) {}, - } - loginCmd, _ := newLoginCmd(mockAuth, mockUserInterface, test.isCloud, req, AuthTokenHandler, mockLoginCredentialsManager, LoginOrganizationManager) + ctrl := gomock.NewController(t) + mockLoginCredentialsManager := climock.NewMockLoginCredentialsManager(ctrl) + // With --prompt, the env-var credential getters must never be invoked. + mockLoginCredentialsManager.EXPECT().GetCloudCredentialsFromEnvVar(gomock.Any()).Times(0) + mockLoginCredentialsManager.EXPECT().GetOnPremCredentialsFromEnvVar().Times(0) + mockLoginCredentialsManager.EXPECT().GetCloudCredentialsFromPrompt(gomock.Any()).Return(func() (*pauth.Credentials, error) { + return &pauth.Credentials{ + Username: promptUser, + Password: promptPassword, + }, nil + }).AnyTimes() + mockLoginCredentialsManager.EXPECT().GetOnPremCredentialsFromPrompt().Return(func() (*pauth.Credentials, error) { + return &pauth.Credentials{ + Username: promptUser, + Password: promptPassword, + }, nil + }).AnyTimes() + mockLoginCredentialsManager.EXPECT().SetCloudClient(gomock.Any()).AnyTimes() + loginCmd, _ := newLoginCmd(ctrl, mockAuth, mockUserInterface, test.isCloud, req, newTestAuthTokenHandler(ctrl), mockLoginCredentialsManager, newTestLoginOrganizationManager(ctrl)) loginArgs := []string{"--prompt"} if !test.isCloud { loginArgs = append(loginArgs, "--url", "http://localhost:8090") @@ -494,9 +443,6 @@ func TestPromptLoginFlag(t *testing.T) { output, err := pcmd.ExecuteCommand(loginCmd, loginArgs...) req.NoError(err) - req.False(mockLoginCredentialsManager.GetCloudCredentialsFromEnvVarCalled()) - req.False(mockLoginCredentialsManager.GetOnPremCredentialsFromEnvVarCalled()) - if test.isCloud { req.Contains(output, fmt.Sprintf(errors.LoggedInAsMsgWithOrg, promptUser, organizationId1, "")) } else { @@ -508,30 +454,22 @@ func TestPromptLoginFlag(t *testing.T) { func TestLoginFail(t *testing.T) { req := require.New(t) - mockLoginCredentialsManager := &climock.LoginCredentialsManager{ - GetCloudCredentialsFromEnvVarFunc: func(_ string) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, fmt.Errorf("DO NOT RETURN THIS ERR") - } - }, - GetCredentialsFromConfigFunc: func(_ *config.Config, _ config.MachineParams) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - GetCloudCredentialsFromPromptFunc: func(_ string) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, &ccloudv1.InvalidLoginError{} - } - }, - GetCredentialsFromKeychainFunc: func(_ bool, _, _ string) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - SetCloudClientFunc: func(_ *ccloudv1.Client) {}, - } - loginCmd, _ := newLoginCmd(mockAuth, mockUserInterface, true, req, AuthTokenHandler, mockLoginCredentialsManager, LoginOrganizationManager) + ctrl := gomock.NewController(t) + mockLoginCredentialsManager := climock.NewMockLoginCredentialsManager(ctrl) + mockLoginCredentialsManager.EXPECT().GetCloudCredentialsFromEnvVar(gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, fmt.Errorf("DO NOT RETURN THIS ERR") + }).AnyTimes() + mockLoginCredentialsManager.EXPECT().GetCredentialsFromConfig(gomock.Any(), gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + mockLoginCredentialsManager.EXPECT().GetCloudCredentialsFromPrompt(gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, &ccloudv1.InvalidLoginError{} + }).AnyTimes() + mockLoginCredentialsManager.EXPECT().GetCredentialsFromKeychain(gomock.Any(), gomock.Any(), gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + mockLoginCredentialsManager.EXPECT().SetCloudClient(gomock.Any()).AnyTimes() + loginCmd, _ := newLoginCmd(ctrl, mockAuth, mockUserInterface, true, req, newTestAuthTokenHandler(ctrl), mockLoginCredentialsManager, newTestLoginOrganizationManager(ctrl)) _, err := pcmd.ExecuteCommand(loginCmd) req.Error(err) req.Equal(new(ccloudv1.InvalidLoginError), err) @@ -566,6 +504,7 @@ func Test_SelfSignedCerts(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { + ctrl := gomock.NewController(t) if test.setEnv { os.Setenv(pauth.ConfluentPlatformCertificateAuthorityPath, "testcert.pem") } @@ -577,7 +516,7 @@ func Test_SelfSignedCerts(t *testing.T) { } else { expectedCaCert = test.caCertPathFlag } - loginCmd := getNewLoginCommandForSelfSignedCertTest(req, cfg, expectedCaCert) + loginCmd := getNewLoginCommandForSelfSignedCertTest(ctrl, req, cfg, expectedCaCert) _, err := pcmd.ExecuteCommand(loginCmd, "--url", "http://localhost:8090", "--certificate-authority-path", test.caCertPathFlag) req.NoError(err) @@ -602,7 +541,7 @@ func Test_SelfSignedCerts(t *testing.T) { } } -func getNewLoginCommandForSelfSignedCertTest(req *require.Assertions, cfg *config.Config, expectedCaCertPath string) *cobra.Command { +func getNewLoginCommandForSelfSignedCertTest(ctrl *gomock.Controller, req *require.Assertions, cfg *config.Config, expectedCaCertPath string) *cobra.Command { mdsConfig := mdsv1.NewConfiguration() mdsClient := mdsv1.NewAPIClient(mdsConfig) @@ -635,18 +574,17 @@ func getNewLoginCommandForSelfSignedCertTest(req *require.Assertions, cfg *confi return mockAuthResponse, nil, nil }, } - mdsClientManager := &climock.MDSClientManager{ - GetMDSClientFunc: func(_, caCertPath, _, _ string, _ bool) (*mdsv1.APIClient, error) { - // ensure the right caCertPath is used - req.Contains(caCertPath, expectedCaCertPath) - mdsClient.GetConfig().HTTPClient, err = utils.SelfSignedCertClient(certReader, tls.Certificate{}) - if err != nil { - return nil, err - } - return mdsClient, nil - }, - } - loginCmd := New(cfg, prerunner, nil, mdsClientManager, mockLoginCredentialsManager, LoginOrganizationManager, AuthTokenHandler) + mdsClientManager := climock.NewMockMDSClientManager(ctrl) + mdsClientManager.EXPECT().GetMDSClient(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(_, caCertPath, _, _ string, _ bool) (*mdsv1.APIClient, error) { + // ensure the right caCertPath is used + req.Contains(caCertPath, expectedCaCertPath) + mdsClient.GetConfig().HTTPClient, err = utils.SelfSignedCertClient(certReader, tls.Certificate{}) + if err != nil { + return nil, err + } + return mdsClient, nil + }).AnyTimes() + loginCmd := New(cfg, prerunner, nil, mdsClientManager, newTestLoginCredentialsManager(ctrl), newTestLoginOrganizationManager(ctrl), newTestAuthTokenHandler(ctrl)) loginCmd.Flags().Bool("unsafe-trace", false, "") loginCmd.PersistentFlags().CountP("verbose", "v", "Increase output verbosity") @@ -655,6 +593,7 @@ func getNewLoginCommandForSelfSignedCertTest(req *require.Assertions, cfg *confi func TestLoginWithExistingContext(t *testing.T) { req := require.New(t) + ctrl := gomock.NewController(t) auth := &ccloudv1mock.Auth{ LoginFunc: func(_ *ccloudv1.AuthenticateRequest) (*ccloudv1.AuthenticateReply, error) { return &ccloudv1.AuthenticateReply{Token: testToken1}, nil @@ -704,7 +643,7 @@ func TestLoginWithExistingContext(t *testing.T) { } for _, s := range suite { - loginCmd, cfg := newLoginCmd(auth, userInterface, s.isCloud, req, AuthTokenHandler, mockLoginCredentialsManager, LoginOrganizationManager) + loginCmd, cfg := newLoginCmd(ctrl, auth, userInterface, s.isCloud, req, newTestAuthTokenHandler(ctrl), newTestLoginCredentialsManager(ctrl), newTestLoginOrganizationManager(ctrl)) // Login to the CLI control plane _, err := pcmd.ExecuteCommand(loginCmd, s.args...) @@ -717,7 +656,7 @@ func TestLoginWithExistingContext(t *testing.T) { ctx.KafkaClusterContext.SetActiveKafkaCluster(kafkaCluster.ID) // Executing logout - logoutCmd := newLogoutCmd(auth, userInterface, s.isCloud, req, AuthTokenHandler, cfg) + logoutCmd := newLogoutCmd(ctrl, auth, userInterface, s.isCloud, req, newTestAuthTokenHandler(ctrl), cfg) _, err = pcmd.ExecuteCommand(logoutCmd) req.NoError(err) verifyLoggedOutState(t, cfg, ctx.Name) @@ -802,23 +741,20 @@ func TestValidateUrl(t *testing.T) { } } -func newLoginCmd(auth *ccloudv1mock.Auth, userInterface *ccloudv1mock.UserInterface, isCloud bool, req *require.Assertions, authTokenHandler pauth.AuthTokenHandler, loginCredentialsManager pauth.LoginCredentialsManager, loginOrganizationManager pauth.LoginOrganizationManager) (*cobra.Command, *config.Config) { +func newLoginCmd(ctrl *gomock.Controller, auth *ccloudv1mock.Auth, userInterface *ccloudv1mock.UserInterface, isCloud bool, req *require.Assertions, authTokenHandler pauth.AuthTokenHandler, loginCredentialsManager pauth.LoginCredentialsManager, loginOrganizationManager pauth.LoginOrganizationManager) (*cobra.Command, *config.Config) { config.SetTempHomeDir() cfg := config.New() - var ccloudClientFactory *climock.CCloudClientFactory - var mdsClientManager *climock.MDSClientManager + var ccloudClientFactory *climock.MockCCloudClientFactory + var mdsClientManager *climock.MockMDSClientManager var prerunner pcmd.PreRunner if !isCloud { mdsClient := climock.NewMdsClientMock(testToken1) - mdsClientManager = &climock.MDSClientManager{ - GetMDSClientFunc: func(_, _, _, _ string, _ bool) (*mdsv1.APIClient, error) { - return mdsClient, nil - }, - } + mdsClientManager = climock.NewMockMDSClientManager(ctrl) + mdsClientManager.EXPECT().GetMDSClient(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(mdsClient, nil).AnyTimes() prerunner = climock.NewPreRunnerMock(nil, nil, mdsClient, nil, cfg) } else { - ccloudClientFactory = climock.NewCCloudClientFactoryMock(auth, userInterface, req) + ccloudClientFactory = climock.NewCCloudClientFactoryMock(ctrl, auth, userInterface, req) prerunner = climock.NewPreRunnerMock(ccloudClientFactory.AnonHTTPClientFactory(ccloudURL), nil, nil, nil, cfg) } @@ -827,11 +763,11 @@ func newLoginCmd(auth *ccloudv1mock.Auth, userInterface *ccloudv1mock.UserInterf return loginCmd, cfg } -func newLogoutCmd(auth *ccloudv1mock.Auth, userInterface *ccloudv1mock.UserInterface, isCloud bool, req *require.Assertions, authTokenHandler pauth.AuthTokenHandler, cfg *config.Config) *cobra.Command { +func newLogoutCmd(ctrl *gomock.Controller, auth *ccloudv1mock.Auth, userInterface *ccloudv1mock.UserInterface, isCloud bool, req *require.Assertions, authTokenHandler pauth.AuthTokenHandler, cfg *config.Config) *cobra.Command { var prerunner pcmd.PreRunner if isCloud { - ccloudClientFactory := climock.NewCCloudClientFactoryMock(auth, userInterface, req) + ccloudClientFactory := climock.NewCCloudClientFactoryMock(ctrl, auth, userInterface, req) prerunner = climock.NewPreRunnerMock(ccloudClientFactory.AnonHTTPClientFactory(ccloudURL), nil, nil, nil, cfg) } else { mdsClient := climock.NewMdsClientMock(testToken1) diff --git a/internal/logout/command_test.go b/internal/logout/command_test.go index a4a865251f..d2d7f085db 100644 --- a/internal/logout/command_test.go +++ b/internal/logout/command_test.go @@ -5,10 +5,10 @@ import ( "github.com/spf13/cobra" "github.com/stretchr/testify/require" + "go.uber.org/mock/gomock" ccloudv1 "github.com/confluentinc/ccloud-sdk-go-v1-public" ccloudv1mock "github.com/confluentinc/ccloud-sdk-go-v1-public/mock" - "github.com/confluentinc/mds-sdk-go-public/mdsv1" climock "github.com/confluentinc/cli/v4/mock" pauth "github.com/confluentinc/cli/v4/pkg/auth" @@ -23,37 +23,25 @@ const ( ccloudURL = "https://confluent.cloud" ) -var ( - orgManagerImpl = pauth.NewLoginOrganizationManagerImpl() - LoginOrganizationManager = &climock.LoginOrganizationManager{ - GetLoginOrganizationFromFlagFunc: func(cmd *cobra.Command) func() string { - return orgManagerImpl.GetLoginOrganizationFromFlag(cmd) - }, - GetLoginOrganizationFromEnvironmentVariableFunc: func() func() string { - return orgManagerImpl.GetLoginOrganizationFromEnvironmentVariable() - }, - } - AuthTokenHandler = &climock.AuthTokenHandler{ - GetCCloudTokensFunc: func(_ pauth.CCloudClientFactory, _ string, _ *pauth.Credentials, _ bool, _ string) (string, string, error) { - return testToken, "refreshToken", nil - }, - GetConfluentTokenFunc: func(_ *mdsv1.APIClient, _ *pauth.Credentials, _ bool) (string, string, error) { - return testToken, "", nil - }, - } -) +func newTestAuthTokenHandler(ctrl *gomock.Controller) *climock.MockAuthTokenHandler { + authTokenHandler := climock.NewMockAuthTokenHandler(ctrl) + authTokenHandler.EXPECT().GetCCloudTokens(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(testToken, "refreshToken", nil).AnyTimes() + authTokenHandler.EXPECT().GetConfluentToken(gomock.Any(), gomock.Any(), gomock.Any()).Return(testToken, "", nil).AnyTimes() + return authTokenHandler +} func TestLogout(t *testing.T) { req := require.New(t) cfg := config.AuthenticatedConfigMockWithContextName(config.MockContextName) contextName := cfg.Context().Name - logoutCmd, cfg := newLogoutCmd(getAuthMock(), nil, true, req, AuthTokenHandler, contextName) + ctrl := gomock.NewController(t) + logoutCmd, cfg := newLogoutCmd(ctrl, getAuthMock(), nil, true, req, newTestAuthTokenHandler(ctrl), contextName) _, err := pcmd.ExecuteCommand(logoutCmd) req.NoError(err) verifyLoggedOutState(t, cfg, contextName) } -func newLogoutCmd(auth *ccloudv1mock.Auth, userInterface *ccloudv1mock.UserInterface, isCloud bool, req *require.Assertions, authTokenHandler pauth.AuthTokenHandler, contextName string) (*cobra.Command, *config.Config) { +func newLogoutCmd(ctrl *gomock.Controller, auth *ccloudv1mock.Auth, userInterface *ccloudv1mock.UserInterface, isCloud bool, req *require.Assertions, authTokenHandler pauth.AuthTokenHandler, contextName string) (*cobra.Command, *config.Config) { config.SetTempHomeDir() cfg := config.AuthenticatedConfigMockWithContextName(contextName) var prerunner pcmd.PreRunner @@ -62,7 +50,7 @@ func newLogoutCmd(auth *ccloudv1mock.Auth, userInterface *ccloudv1mock.UserInter mdsClient := climock.NewMdsClientMock(testToken) prerunner = climock.NewPreRunnerMock(nil, nil, mdsClient, nil, cfg) } else { - ccloudClientFactory := climock.NewCCloudClientFactoryMock(auth, userInterface, req) + ccloudClientFactory := climock.NewCCloudClientFactoryMock(ctrl, auth, userInterface, req) prerunner = climock.NewPreRunnerMock(ccloudClientFactory.AnonHTTPClientFactory(ccloudURL), nil, nil, nil, cfg) } logoutCmd := New(cfg, prerunner, authTokenHandler) diff --git a/mock/auth_mds_client.go b/mock/auth_mds_client.go index 9e257ca5e9..980129a674 100644 --- a/mock/auth_mds_client.go +++ b/mock/auth_mds_client.go @@ -1,84 +1,80 @@ -// Code generated by mocker. DO NOT EDIT. -// github.com/travisjeffery/mocker -// Source: pkg/auth/mds_client.go +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/confluentinc/cli/v4/pkg/auth (interfaces: MDSClientManager) +// +// Generated by this command: +// +// mockgen -typed -destination=../../mock/auth_mds_client.go -package=mock github.com/confluentinc/cli/v4/pkg/auth MDSClientManager +// +// Package mock is a generated GoMock package. package mock import ( - sync "sync" + reflect "reflect" - github_com_confluentinc_mds_sdk_go_public_mdsv1 "github.com/confluentinc/mds-sdk-go-public/mdsv1" + mdsv1 "github.com/confluentinc/mds-sdk-go-public/mdsv1" + gomock "go.uber.org/mock/gomock" ) -// MDSClientManager is a mock of MDSClientManager interface -type MDSClientManager struct { - lockGetMDSClient sync.Mutex - GetMDSClientFunc func(url, caCertPath, clientCertPath, clientKeyPath string, unsafeTrace bool) (*github_com_confluentinc_mds_sdk_go_public_mdsv1.APIClient, error) - - calls struct { - GetMDSClient []struct { - Url string - CaCertPath string - ClientCertPath string - ClientKeyPath string - UnsafeTrace bool - } - } +// MockMDSClientManager is a mock of MDSClientManager interface. +type MockMDSClientManager struct { + ctrl *gomock.Controller + recorder *MockMDSClientManagerMockRecorder + isgomock struct{} } -// GetMDSClient mocks base method by wrapping the associated func. -func (m *MDSClientManager) GetMDSClient(url, caCertPath, clientCertPath, clientKeyPath string, unsafeTrace bool) (*github_com_confluentinc_mds_sdk_go_public_mdsv1.APIClient, error) { - m.lockGetMDSClient.Lock() - defer m.lockGetMDSClient.Unlock() - - if m.GetMDSClientFunc == nil { - panic("mocker: MDSClientManager.GetMDSClientFunc is nil but MDSClientManager.GetMDSClient was called.") - } +// MockMDSClientManagerMockRecorder is the mock recorder for MockMDSClientManager. +type MockMDSClientManagerMockRecorder struct { + mock *MockMDSClientManager +} - call := struct { - Url string - CaCertPath string - ClientCertPath string - ClientKeyPath string - UnsafeTrace bool - }{ - Url: url, - CaCertPath: caCertPath, - ClientCertPath: clientCertPath, - ClientKeyPath: clientKeyPath, - UnsafeTrace: unsafeTrace, - } +// NewMockMDSClientManager creates a new mock instance. +func NewMockMDSClientManager(ctrl *gomock.Controller) *MockMDSClientManager { + mock := &MockMDSClientManager{ctrl: ctrl} + mock.recorder = &MockMDSClientManagerMockRecorder{mock} + return mock +} - m.calls.GetMDSClient = append(m.calls.GetMDSClient, call) +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockMDSClientManager) EXPECT() *MockMDSClientManagerMockRecorder { + return m.recorder +} - return m.GetMDSClientFunc(url, caCertPath, clientCertPath, clientKeyPath, unsafeTrace) +// GetMDSClient mocks base method. +func (m *MockMDSClientManager) GetMDSClient(url, caCertPath, clientCertPath, clientKeyPath string, unsafeTrace bool) (*mdsv1.APIClient, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetMDSClient", url, caCertPath, clientCertPath, clientKeyPath, unsafeTrace) + ret0, _ := ret[0].(*mdsv1.APIClient) + ret1, _ := ret[1].(error) + return ret0, ret1 } -// GetMDSClientCalled returns true if GetMDSClient was called at least once. -func (m *MDSClientManager) GetMDSClientCalled() bool { - m.lockGetMDSClient.Lock() - defer m.lockGetMDSClient.Unlock() +// GetMDSClient indicates an expected call of GetMDSClient. +func (mr *MockMDSClientManagerMockRecorder) GetMDSClient(url, caCertPath, clientCertPath, clientKeyPath, unsafeTrace any) *MockMDSClientManagerGetMDSClientCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMDSClient", reflect.TypeOf((*MockMDSClientManager)(nil).GetMDSClient), url, caCertPath, clientCertPath, clientKeyPath, unsafeTrace) + return &MockMDSClientManagerGetMDSClientCall{Call: call} +} - return len(m.calls.GetMDSClient) > 0 +// MockMDSClientManagerGetMDSClientCall wrap *gomock.Call +type MockMDSClientManagerGetMDSClientCall struct { + *gomock.Call } -// GetMDSClientCalls returns the calls made to GetMDSClient. -func (m *MDSClientManager) GetMDSClientCalls() []struct { - Url string - CaCertPath string - ClientCertPath string - ClientKeyPath string - UnsafeTrace bool -} { - m.lockGetMDSClient.Lock() - defer m.lockGetMDSClient.Unlock() +// Return rewrite *gomock.Call.Return +func (c *MockMDSClientManagerGetMDSClientCall) Return(arg0 *mdsv1.APIClient, arg1 error) *MockMDSClientManagerGetMDSClientCall { + c.Call = c.Call.Return(arg0, arg1) + return c +} - return m.calls.GetMDSClient +// Do rewrite *gomock.Call.Do +func (c *MockMDSClientManagerGetMDSClientCall) Do(f func(string, string, string, string, bool) (*mdsv1.APIClient, error)) *MockMDSClientManagerGetMDSClientCall { + c.Call = c.Call.Do(f) + return c } -// Reset resets the calls made to the mocked methods. -func (m *MDSClientManager) Reset() { - m.lockGetMDSClient.Lock() - m.calls.GetMDSClient = nil - m.lockGetMDSClient.Unlock() +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockMDSClientManagerGetMDSClientCall) DoAndReturn(f func(string, string, string, string, bool) (*mdsv1.APIClient, error)) *MockMDSClientManagerGetMDSClientCall { + c.Call = c.Call.DoAndReturn(f) + return c } diff --git a/mock/auth_token_handler.go b/mock/auth_token_handler.go index c4a810387d..7da5948416 100644 --- a/mock/auth_token_handler.go +++ b/mock/auth_token_handler.go @@ -1,140 +1,122 @@ -// Code generated by mocker. DO NOT EDIT. -// github.com/travisjeffery/mocker -// Source: auth_token_handler.go - +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/confluentinc/cli/v4/pkg/auth (interfaces: AuthTokenHandler) +// +// Generated by this command: +// +// mockgen -typed -destination=../../mock/auth_token_handler.go -package=mock github.com/confluentinc/cli/v4/pkg/auth AuthTokenHandler +// + +// Package mock is a generated GoMock package. package mock import ( - sync "sync" + reflect "reflect" - github_com_confluentinc_cli_v3_pkg_auth "github.com/confluentinc/cli/v4/pkg/auth" - github_com_confluentinc_mds_sdk_go_public_mdsv1 "github.com/confluentinc/mds-sdk-go-public/mdsv1" + auth "github.com/confluentinc/cli/v4/pkg/auth" + mdsv1 "github.com/confluentinc/mds-sdk-go-public/mdsv1" + gomock "go.uber.org/mock/gomock" ) -// AuthTokenHandler is a mock of AuthTokenHandler interface -type AuthTokenHandler struct { - lockGetCCloudTokens sync.Mutex - GetCCloudTokensFunc func(arg0 github_com_confluentinc_cli_v3_pkg_auth.CCloudClientFactory, arg1 string, arg2 *github_com_confluentinc_cli_v3_pkg_auth.Credentials, arg3 bool, arg4 string) (string, string, error) - - lockGetConfluentToken sync.Mutex - GetConfluentTokenFunc func(arg0 *github_com_confluentinc_mds_sdk_go_public_mdsv1.APIClient, arg1 *github_com_confluentinc_cli_v3_pkg_auth.Credentials, arg2 bool) (string, string, error) - - calls struct { - GetCCloudTokens []struct { - Arg0 github_com_confluentinc_cli_v3_pkg_auth.CCloudClientFactory - Arg1 string - Arg2 *github_com_confluentinc_cli_v3_pkg_auth.Credentials - Arg3 bool - Arg4 string - } - GetConfluentToken []struct { - Arg0 *github_com_confluentinc_mds_sdk_go_public_mdsv1.APIClient - Arg1 *github_com_confluentinc_cli_v3_pkg_auth.Credentials - Arg2 bool - } - } -} - -// GetCCloudTokens mocks base method by wrapping the associated func. -func (m *AuthTokenHandler) GetCCloudTokens(arg0 github_com_confluentinc_cli_v3_pkg_auth.CCloudClientFactory, arg1 string, arg2 *github_com_confluentinc_cli_v3_pkg_auth.Credentials, arg3 bool, arg4 string) (string, string, error) { - m.lockGetCCloudTokens.Lock() - defer m.lockGetCCloudTokens.Unlock() - - if m.GetCCloudTokensFunc == nil { - panic("mocker: AuthTokenHandler.GetCCloudTokensFunc is nil but AuthTokenHandler.GetCCloudTokens was called.") - } - - call := struct { - Arg0 github_com_confluentinc_cli_v3_pkg_auth.CCloudClientFactory - Arg1 string - Arg2 *github_com_confluentinc_cli_v3_pkg_auth.Credentials - Arg3 bool - Arg4 string - }{ - Arg0: arg0, - Arg1: arg1, - Arg2: arg2, - Arg3: arg3, - Arg4: arg4, - } - - m.calls.GetCCloudTokens = append(m.calls.GetCCloudTokens, call) - - return m.GetCCloudTokensFunc(arg0, arg1, arg2, arg3, arg4) -} - -// GetCCloudTokensCalled returns true if GetCCloudTokens was called at least once. -func (m *AuthTokenHandler) GetCCloudTokensCalled() bool { - m.lockGetCCloudTokens.Lock() - defer m.lockGetCCloudTokens.Unlock() - - return len(m.calls.GetCCloudTokens) > 0 -} - -// GetCCloudTokensCalls returns the calls made to GetCCloudTokens. -func (m *AuthTokenHandler) GetCCloudTokensCalls() []struct { - Arg0 github_com_confluentinc_cli_v3_pkg_auth.CCloudClientFactory - Arg1 string - Arg2 *github_com_confluentinc_cli_v3_pkg_auth.Credentials - Arg3 bool - Arg4 string -} { - m.lockGetCCloudTokens.Lock() - defer m.lockGetCCloudTokens.Unlock() - - return m.calls.GetCCloudTokens -} - -// GetConfluentToken mocks base method by wrapping the associated func. -func (m *AuthTokenHandler) GetConfluentToken(arg0 *github_com_confluentinc_mds_sdk_go_public_mdsv1.APIClient, arg1 *github_com_confluentinc_cli_v3_pkg_auth.Credentials, arg2 bool) (string, string, error) { - m.lockGetConfluentToken.Lock() - defer m.lockGetConfluentToken.Unlock() - - if m.GetConfluentTokenFunc == nil { - panic("mocker: AuthTokenHandler.GetConfluentTokenFunc is nil but AuthTokenHandler.GetConfluentToken was called.") - } - - call := struct { - Arg0 *github_com_confluentinc_mds_sdk_go_public_mdsv1.APIClient - Arg1 *github_com_confluentinc_cli_v3_pkg_auth.Credentials - Arg2 bool - }{ - Arg0: arg0, - Arg1: arg1, - Arg2: arg2, - } - - m.calls.GetConfluentToken = append(m.calls.GetConfluentToken, call) - - return m.GetConfluentTokenFunc(arg0, arg1, arg2) -} - -// GetConfluentTokenCalled returns true if GetConfluentToken was called at least once. -func (m *AuthTokenHandler) GetConfluentTokenCalled() bool { - m.lockGetConfluentToken.Lock() - defer m.lockGetConfluentToken.Unlock() - - return len(m.calls.GetConfluentToken) > 0 -} - -// GetConfluentTokenCalls returns the calls made to GetConfluentToken. -func (m *AuthTokenHandler) GetConfluentTokenCalls() []struct { - Arg0 *github_com_confluentinc_mds_sdk_go_public_mdsv1.APIClient - Arg1 *github_com_confluentinc_cli_v3_pkg_auth.Credentials - Arg2 bool -} { - m.lockGetConfluentToken.Lock() - defer m.lockGetConfluentToken.Unlock() - - return m.calls.GetConfluentToken -} - -// Reset resets the calls made to the mocked methods. -func (m *AuthTokenHandler) Reset() { - m.lockGetCCloudTokens.Lock() - m.calls.GetCCloudTokens = nil - m.lockGetCCloudTokens.Unlock() - m.lockGetConfluentToken.Lock() - m.calls.GetConfluentToken = nil - m.lockGetConfluentToken.Unlock() +// MockAuthTokenHandler is a mock of AuthTokenHandler interface. +type MockAuthTokenHandler struct { + ctrl *gomock.Controller + recorder *MockAuthTokenHandlerMockRecorder + isgomock struct{} +} + +// MockAuthTokenHandlerMockRecorder is the mock recorder for MockAuthTokenHandler. +type MockAuthTokenHandlerMockRecorder struct { + mock *MockAuthTokenHandler +} + +// NewMockAuthTokenHandler creates a new mock instance. +func NewMockAuthTokenHandler(ctrl *gomock.Controller) *MockAuthTokenHandler { + mock := &MockAuthTokenHandler{ctrl: ctrl} + mock.recorder = &MockAuthTokenHandlerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockAuthTokenHandler) EXPECT() *MockAuthTokenHandlerMockRecorder { + return m.recorder +} + +// GetCCloudTokens mocks base method. +func (m *MockAuthTokenHandler) GetCCloudTokens(arg0 auth.CCloudClientFactory, arg1 string, arg2 *auth.Credentials, arg3 bool, arg4 string) (string, string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCCloudTokens", arg0, arg1, arg2, arg3, arg4) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(string) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetCCloudTokens indicates an expected call of GetCCloudTokens. +func (mr *MockAuthTokenHandlerMockRecorder) GetCCloudTokens(arg0, arg1, arg2, arg3, arg4 any) *MockAuthTokenHandlerGetCCloudTokensCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCCloudTokens", reflect.TypeOf((*MockAuthTokenHandler)(nil).GetCCloudTokens), arg0, arg1, arg2, arg3, arg4) + return &MockAuthTokenHandlerGetCCloudTokensCall{Call: call} +} + +// MockAuthTokenHandlerGetCCloudTokensCall wrap *gomock.Call +type MockAuthTokenHandlerGetCCloudTokensCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockAuthTokenHandlerGetCCloudTokensCall) Return(arg0, arg1 string, arg2 error) *MockAuthTokenHandlerGetCCloudTokensCall { + c.Call = c.Call.Return(arg0, arg1, arg2) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockAuthTokenHandlerGetCCloudTokensCall) Do(f func(auth.CCloudClientFactory, string, *auth.Credentials, bool, string) (string, string, error)) *MockAuthTokenHandlerGetCCloudTokensCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockAuthTokenHandlerGetCCloudTokensCall) DoAndReturn(f func(auth.CCloudClientFactory, string, *auth.Credentials, bool, string) (string, string, error)) *MockAuthTokenHandlerGetCCloudTokensCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// GetConfluentToken mocks base method. +func (m *MockAuthTokenHandler) GetConfluentToken(arg0 *mdsv1.APIClient, arg1 *auth.Credentials, arg2 bool) (string, string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetConfluentToken", arg0, arg1, arg2) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(string) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetConfluentToken indicates an expected call of GetConfluentToken. +func (mr *MockAuthTokenHandlerMockRecorder) GetConfluentToken(arg0, arg1, arg2 any) *MockAuthTokenHandlerGetConfluentTokenCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetConfluentToken", reflect.TypeOf((*MockAuthTokenHandler)(nil).GetConfluentToken), arg0, arg1, arg2) + return &MockAuthTokenHandlerGetConfluentTokenCall{Call: call} +} + +// MockAuthTokenHandlerGetConfluentTokenCall wrap *gomock.Call +type MockAuthTokenHandlerGetConfluentTokenCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockAuthTokenHandlerGetConfluentTokenCall) Return(arg0, arg1 string, arg2 error) *MockAuthTokenHandlerGetConfluentTokenCall { + c.Call = c.Call.Return(arg0, arg1, arg2) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockAuthTokenHandlerGetConfluentTokenCall) Do(f func(*mdsv1.APIClient, *auth.Credentials, bool) (string, string, error)) *MockAuthTokenHandlerGetConfluentTokenCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockAuthTokenHandlerGetConfluentTokenCall) DoAndReturn(f func(*mdsv1.APIClient, *auth.Credentials, bool) (string, string, error)) *MockAuthTokenHandlerGetConfluentTokenCall { + c.Call = c.Call.DoAndReturn(f) + return c } diff --git a/mock/ccloud_client_factory.go b/mock/ccloud_client_factory.go index 18fc348404..2f294980c3 100644 --- a/mock/ccloud_client_factory.go +++ b/mock/ccloud_client_factory.go @@ -1,124 +1,118 @@ -// Code generated by mocker. DO NOT EDIT. -// github.com/travisjeffery/mocker -// Source: internal/pkg/auth/ccloud_client_factory.go - +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/confluentinc/cli/v4/pkg/auth (interfaces: CCloudClientFactory) +// +// Generated by this command: +// +// mockgen -typed -destination=../../mock/ccloud_client_factory.go -package=mock github.com/confluentinc/cli/v4/pkg/auth CCloudClientFactory +// + +// Package mock is a generated GoMock package. package mock import ( context "context" - sync "sync" + reflect "reflect" - github_com_confluentinc_ccloud_sdk_go_v1_public "github.com/confluentinc/ccloud-sdk-go-v1-public" + ccloud "github.com/confluentinc/ccloud-sdk-go-v1-public" + gomock "go.uber.org/mock/gomock" ) -// CCloudClientFactory is a mock of CCloudClientFactory interface -type CCloudClientFactory struct { - lockAnonHTTPClientFactory sync.Mutex - AnonHTTPClientFactoryFunc func(baseURL string) *github_com_confluentinc_ccloud_sdk_go_v1_public.Client - - lockJwtHTTPClientFactory sync.Mutex - JwtHTTPClientFactoryFunc func(ctx context.Context, jwt, baseURL string) *github_com_confluentinc_ccloud_sdk_go_v1_public.Client - - calls struct { - AnonHTTPClientFactory []struct { - BaseURL string - } - JwtHTTPClientFactory []struct { - Ctx context.Context - Jwt string - BaseURL string - } - } +// MockCCloudClientFactory is a mock of CCloudClientFactory interface. +type MockCCloudClientFactory struct { + ctrl *gomock.Controller + recorder *MockCCloudClientFactoryMockRecorder + isgomock struct{} } -// AnonHTTPClientFactory mocks base method by wrapping the associated func. -func (m *CCloudClientFactory) AnonHTTPClientFactory(baseURL string) *github_com_confluentinc_ccloud_sdk_go_v1_public.Client { - m.lockAnonHTTPClientFactory.Lock() - defer m.lockAnonHTTPClientFactory.Unlock() - - if m.AnonHTTPClientFactoryFunc == nil { - panic("mocker: CCloudClientFactory.AnonHTTPClientFactoryFunc is nil but CCloudClientFactory.AnonHTTPClientFactory was called.") - } - - call := struct { - BaseURL string - }{ - BaseURL: baseURL, - } - - m.calls.AnonHTTPClientFactory = append(m.calls.AnonHTTPClientFactory, call) - - return m.AnonHTTPClientFactoryFunc(baseURL) +// MockCCloudClientFactoryMockRecorder is the mock recorder for MockCCloudClientFactory. +type MockCCloudClientFactoryMockRecorder struct { + mock *MockCCloudClientFactory } -// AnonHTTPClientFactoryCalled returns true if AnonHTTPClientFactory was called at least once. -func (m *CCloudClientFactory) AnonHTTPClientFactoryCalled() bool { - m.lockAnonHTTPClientFactory.Lock() - defer m.lockAnonHTTPClientFactory.Unlock() +// NewMockCCloudClientFactory creates a new mock instance. +func NewMockCCloudClientFactory(ctrl *gomock.Controller) *MockCCloudClientFactory { + mock := &MockCCloudClientFactory{ctrl: ctrl} + mock.recorder = &MockCCloudClientFactoryMockRecorder{mock} + return mock +} - return len(m.calls.AnonHTTPClientFactory) > 0 +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockCCloudClientFactory) EXPECT() *MockCCloudClientFactoryMockRecorder { + return m.recorder } -// AnonHTTPClientFactoryCalls returns the calls made to AnonHTTPClientFactory. -func (m *CCloudClientFactory) AnonHTTPClientFactoryCalls() []struct { - BaseURL string -} { - m.lockAnonHTTPClientFactory.Lock() - defer m.lockAnonHTTPClientFactory.Unlock() +// AnonHTTPClientFactory mocks base method. +func (m *MockCCloudClientFactory) AnonHTTPClientFactory(baseURL string) *ccloud.Client { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AnonHTTPClientFactory", baseURL) + ret0, _ := ret[0].(*ccloud.Client) + return ret0 +} - return m.calls.AnonHTTPClientFactory +// AnonHTTPClientFactory indicates an expected call of AnonHTTPClientFactory. +func (mr *MockCCloudClientFactoryMockRecorder) AnonHTTPClientFactory(baseURL any) *MockCCloudClientFactoryAnonHTTPClientFactoryCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AnonHTTPClientFactory", reflect.TypeOf((*MockCCloudClientFactory)(nil).AnonHTTPClientFactory), baseURL) + return &MockCCloudClientFactoryAnonHTTPClientFactoryCall{Call: call} } -// JwtHTTPClientFactory mocks base method by wrapping the associated func. -func (m *CCloudClientFactory) JwtHTTPClientFactory(ctx context.Context, jwt, baseURL string) *github_com_confluentinc_ccloud_sdk_go_v1_public.Client { - m.lockJwtHTTPClientFactory.Lock() - defer m.lockJwtHTTPClientFactory.Unlock() +// MockCCloudClientFactoryAnonHTTPClientFactoryCall wrap *gomock.Call +type MockCCloudClientFactoryAnonHTTPClientFactoryCall struct { + *gomock.Call +} - if m.JwtHTTPClientFactoryFunc == nil { - panic("mocker: CCloudClientFactory.JwtHTTPClientFactoryFunc is nil but CCloudClientFactory.JwtHTTPClientFactory was called.") - } +// Return rewrite *gomock.Call.Return +func (c *MockCCloudClientFactoryAnonHTTPClientFactoryCall) Return(arg0 *ccloud.Client) *MockCCloudClientFactoryAnonHTTPClientFactoryCall { + c.Call = c.Call.Return(arg0) + return c +} - call := struct { - Ctx context.Context - Jwt string - BaseURL string - }{ - Ctx: ctx, - Jwt: jwt, - BaseURL: baseURL, - } +// Do rewrite *gomock.Call.Do +func (c *MockCCloudClientFactoryAnonHTTPClientFactoryCall) Do(f func(string) *ccloud.Client) *MockCCloudClientFactoryAnonHTTPClientFactoryCall { + c.Call = c.Call.Do(f) + return c +} - m.calls.JwtHTTPClientFactory = append(m.calls.JwtHTTPClientFactory, call) +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockCCloudClientFactoryAnonHTTPClientFactoryCall) DoAndReturn(f func(string) *ccloud.Client) *MockCCloudClientFactoryAnonHTTPClientFactoryCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - return m.JwtHTTPClientFactoryFunc(ctx, jwt, baseURL) +// JwtHTTPClientFactory mocks base method. +func (m *MockCCloudClientFactory) JwtHTTPClientFactory(ctx context.Context, jwt, baseURL string) *ccloud.Client { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "JwtHTTPClientFactory", ctx, jwt, baseURL) + ret0, _ := ret[0].(*ccloud.Client) + return ret0 } -// JwtHTTPClientFactoryCalled returns true if JwtHTTPClientFactory was called at least once. -func (m *CCloudClientFactory) JwtHTTPClientFactoryCalled() bool { - m.lockJwtHTTPClientFactory.Lock() - defer m.lockJwtHTTPClientFactory.Unlock() +// JwtHTTPClientFactory indicates an expected call of JwtHTTPClientFactory. +func (mr *MockCCloudClientFactoryMockRecorder) JwtHTTPClientFactory(ctx, jwt, baseURL any) *MockCCloudClientFactoryJwtHTTPClientFactoryCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "JwtHTTPClientFactory", reflect.TypeOf((*MockCCloudClientFactory)(nil).JwtHTTPClientFactory), ctx, jwt, baseURL) + return &MockCCloudClientFactoryJwtHTTPClientFactoryCall{Call: call} +} - return len(m.calls.JwtHTTPClientFactory) > 0 +// MockCCloudClientFactoryJwtHTTPClientFactoryCall wrap *gomock.Call +type MockCCloudClientFactoryJwtHTTPClientFactoryCall struct { + *gomock.Call } -// JwtHTTPClientFactoryCalls returns the calls made to JwtHTTPClientFactory. -func (m *CCloudClientFactory) JwtHTTPClientFactoryCalls() []struct { - Ctx context.Context - Jwt string - BaseURL string -} { - m.lockJwtHTTPClientFactory.Lock() - defer m.lockJwtHTTPClientFactory.Unlock() +// Return rewrite *gomock.Call.Return +func (c *MockCCloudClientFactoryJwtHTTPClientFactoryCall) Return(arg0 *ccloud.Client) *MockCCloudClientFactoryJwtHTTPClientFactoryCall { + c.Call = c.Call.Return(arg0) + return c +} - return m.calls.JwtHTTPClientFactory +// Do rewrite *gomock.Call.Do +func (c *MockCCloudClientFactoryJwtHTTPClientFactoryCall) Do(f func(context.Context, string, string) *ccloud.Client) *MockCCloudClientFactoryJwtHTTPClientFactoryCall { + c.Call = c.Call.Do(f) + return c } -// Reset resets the calls made to the mocked methods. -func (m *CCloudClientFactory) Reset() { - m.lockAnonHTTPClientFactory.Lock() - m.calls.AnonHTTPClientFactory = nil - m.lockAnonHTTPClientFactory.Unlock() - m.lockJwtHTTPClientFactory.Lock() - m.calls.JwtHTTPClientFactory = nil - m.lockJwtHTTPClientFactory.Unlock() +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockCCloudClientFactoryJwtHTTPClientFactoryCall) DoAndReturn(f func(context.Context, string, string) *ccloud.Client) *MockCCloudClientFactoryJwtHTTPClientFactoryCall { + c.Call = c.Call.DoAndReturn(f) + return c } diff --git a/mock/client.go b/mock/client.go index 44f1fce68e..b1262d82c5 100644 --- a/mock/client.go +++ b/mock/client.go @@ -5,6 +5,7 @@ import ( "net/http" "github.com/stretchr/testify/require" + "go.uber.org/mock/gomock" ccloudv1 "github.com/confluentinc/ccloud-sdk-go-v1-public" ccloudv1mock "github.com/confluentinc/ccloud-sdk-go-v1-public/mock" @@ -12,28 +13,28 @@ import ( mdsmock "github.com/confluentinc/mds-sdk-go-public/mdsv1/mock" ) -func NewCCloudClientFactoryMock(auth *ccloudv1mock.Auth, userInterface *ccloudv1mock.UserInterface, req *require.Assertions) *CCloudClientFactory { - return &CCloudClientFactory{ - AnonHTTPClientFactoryFunc: func(baseURL string) *ccloudv1.Client { - req.Equal("https://confluent.cloud", baseURL) - return &ccloudv1.Client{ - Params: &ccloudv1.Params{HttpClient: new(http.Client)}, - Auth: auth, - User: userInterface, - } - }, - JwtHTTPClientFactoryFunc: func(ctx context.Context, jwt, baseURL string) *ccloudv1.Client { - return &ccloudv1.Client{ - Growth: &ccloudv1mock.Growth{ - GetFreeTrialInfoFunc: func(_ int32) ([]*ccloudv1.GrowthPromoCodeClaim, error) { - return []*ccloudv1.GrowthPromoCodeClaim{}, nil - }, +func NewCCloudClientFactoryMock(ctrl *gomock.Controller, auth *ccloudv1mock.Auth, userInterface *ccloudv1mock.UserInterface, req *require.Assertions) *MockCCloudClientFactory { + factory := NewMockCCloudClientFactory(ctrl) + factory.EXPECT().AnonHTTPClientFactory(gomock.Any()).DoAndReturn(func(baseURL string) *ccloudv1.Client { + req.Equal("https://confluent.cloud", baseURL) + return &ccloudv1.Client{ + Params: &ccloudv1.Params{HttpClient: new(http.Client)}, + Auth: auth, + User: userInterface, + } + }).AnyTimes() + factory.EXPECT().JwtHTTPClientFactory(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(ctx context.Context, jwt, baseURL string) *ccloudv1.Client { + return &ccloudv1.Client{ + Growth: &ccloudv1mock.Growth{ + GetFreeTrialInfoFunc: func(_ int32) ([]*ccloudv1.GrowthPromoCodeClaim, error) { + return []*ccloudv1.GrowthPromoCodeClaim{}, nil }, - Auth: auth, - User: userInterface, - } - }, - } + }, + Auth: auth, + User: userInterface, + } + }).AnyTimes() + return factory } func NewMdsClientMock(token string) *mdsv1.APIClient { diff --git a/mock/confluent_current.go b/mock/confluent_current.go index 544456f6e4..c8f0db550c 100644 --- a/mock/confluent_current.go +++ b/mock/confluent_current.go @@ -1,722 +1,696 @@ -// Code generated by mocker. DO NOT EDIT. -// github.com/travisjeffery/mocker -// Source: confluent_current.go - +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/confluentinc/cli/v4/pkg/local (interfaces: ConfluentCurrent) +// +// Generated by this command: +// +// mockgen -typed -destination=../../mock/confluent_current.go -package=mock github.com/confluentinc/cli/v4/pkg/local ConfluentCurrent +// + +// Package mock is a generated GoMock package. package mock import ( - sync "sync" + reflect "reflect" + + gomock "go.uber.org/mock/gomock" ) -// MockConfluentCurrent is a mock of ConfluentCurrent interface +// MockConfluentCurrent is a mock of ConfluentCurrent interface. type MockConfluentCurrent struct { - lockHasTrackingFile sync.Mutex - HasTrackingFileFunc func() bool - - lockRemoveTrackingFile sync.Mutex - RemoveTrackingFileFunc func() error - - lockGetCurrentDir sync.Mutex - GetCurrentDirFunc func() (string, error) - - lockRemoveCurrentDir sync.Mutex - RemoveCurrentDirFunc func() error - - lockGetDataDir sync.Mutex - GetDataDirFunc func(service string) (string, error) - - lockGetLogsDir sync.Mutex - GetLogsDirFunc func(service string) (string, error) - - lockGetConfigFile sync.Mutex - GetConfigFileFunc func(service string) (string, error) - - lockWriteConfig sync.Mutex - WriteConfigFunc func(service string, config []byte) error - - lockGetLogFile sync.Mutex - GetLogFileFunc func(service string) (string, error) - - lockHasLogFile sync.Mutex - HasLogFileFunc func(service string) (bool, error) - - lockGetPidFile sync.Mutex - GetPidFileFunc func(service string) (string, error) - - lockHasPidFile sync.Mutex - HasPidFileFunc func(service string) (bool, error) - - lockReadPid sync.Mutex - ReadPidFunc func(service string) (int, error) - - lockWritePid sync.Mutex - WritePidFunc func(service string, pid int) error - - lockRemovePidFile sync.Mutex - RemovePidFileFunc func(service string) error - - calls struct { - HasTrackingFile []struct { - } - RemoveTrackingFile []struct { - } - GetCurrentDir []struct { - } - RemoveCurrentDir []struct { - } - GetDataDir []struct { - Service string - } - GetLogsDir []struct { - Service string - } - GetConfigFile []struct { - Service string - } - WriteConfig []struct { - Service string - Config []byte - } - GetLogFile []struct { - Service string - } - HasLogFile []struct { - Service string - } - GetPidFile []struct { - Service string - } - HasPidFile []struct { - Service string - } - ReadPid []struct { - Service string - } - WritePid []struct { - Service string - Pid int - } - RemovePidFile []struct { - Service string - } - } + ctrl *gomock.Controller + recorder *MockConfluentCurrentMockRecorder + isgomock struct{} } -func (m *MockConfluentCurrent) GetConfigFileC3(service string) (string, error) { - //TODO implement me - panic("implement me") +// MockConfluentCurrentMockRecorder is the mock recorder for MockConfluentCurrent. +type MockConfluentCurrentMockRecorder struct { + mock *MockConfluentCurrent } -func (m *MockConfluentCurrent) WriteConfigC3(service string, config []byte) error { - //TODO implement me - panic("implement me") +// NewMockConfluentCurrent creates a new mock instance. +func NewMockConfluentCurrent(ctrl *gomock.Controller) *MockConfluentCurrent { + mock := &MockConfluentCurrent{ctrl: ctrl} + mock.recorder = &MockConfluentCurrentMockRecorder{mock} + return mock } -// HasTrackingFile mocks base method by wrapping the associated func. -func (m *MockConfluentCurrent) HasTrackingFile() bool { - m.lockHasTrackingFile.Lock() - defer m.lockHasTrackingFile.Unlock() - - if m.HasTrackingFileFunc == nil { - panic("mocker: MockConfluentCurrent.HasTrackingFileFunc is nil but MockConfluentCurrent.HasTrackingFile was called.") - } - - call := struct { - }{} - - m.calls.HasTrackingFile = append(m.calls.HasTrackingFile, call) - - return m.HasTrackingFileFunc() +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockConfluentCurrent) EXPECT() *MockConfluentCurrentMockRecorder { + return m.recorder } -// HasTrackingFileCalled returns true if HasTrackingFile was called at least once. -func (m *MockConfluentCurrent) HasTrackingFileCalled() bool { - m.lockHasTrackingFile.Lock() - defer m.lockHasTrackingFile.Unlock() - - return len(m.calls.HasTrackingFile) > 0 +// GetConfigFile mocks base method. +func (m *MockConfluentCurrent) GetConfigFile(service string) (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetConfigFile", service) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 } -// HasTrackingFileCalls returns the calls made to HasTrackingFile. -func (m *MockConfluentCurrent) HasTrackingFileCalls() []struct { -} { - m.lockHasTrackingFile.Lock() - defer m.lockHasTrackingFile.Unlock() +// GetConfigFile indicates an expected call of GetConfigFile. +func (mr *MockConfluentCurrentMockRecorder) GetConfigFile(service any) *MockConfluentCurrentGetConfigFileCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetConfigFile", reflect.TypeOf((*MockConfluentCurrent)(nil).GetConfigFile), service) + return &MockConfluentCurrentGetConfigFileCall{Call: call} +} - return m.calls.HasTrackingFile +// MockConfluentCurrentGetConfigFileCall wrap *gomock.Call +type MockConfluentCurrentGetConfigFileCall struct { + *gomock.Call } -// RemoveTrackingFile mocks base method by wrapping the associated func. -func (m *MockConfluentCurrent) RemoveTrackingFile() error { - m.lockRemoveTrackingFile.Lock() - defer m.lockRemoveTrackingFile.Unlock() +// Return rewrite *gomock.Call.Return +func (c *MockConfluentCurrentGetConfigFileCall) Return(arg0 string, arg1 error) *MockConfluentCurrentGetConfigFileCall { + c.Call = c.Call.Return(arg0, arg1) + return c +} - if m.RemoveTrackingFileFunc == nil { - panic("mocker: MockConfluentCurrent.RemoveTrackingFileFunc is nil but MockConfluentCurrent.RemoveTrackingFile was called.") - } +// Do rewrite *gomock.Call.Do +func (c *MockConfluentCurrentGetConfigFileCall) Do(f func(string) (string, error)) *MockConfluentCurrentGetConfigFileCall { + c.Call = c.Call.Do(f) + return c +} - call := struct { - }{} +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockConfluentCurrentGetConfigFileCall) DoAndReturn(f func(string) (string, error)) *MockConfluentCurrentGetConfigFileCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - m.calls.RemoveTrackingFile = append(m.calls.RemoveTrackingFile, call) +// GetConfigFileC3 mocks base method. +func (m *MockConfluentCurrent) GetConfigFileC3(service string) (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetConfigFileC3", service) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} - return m.RemoveTrackingFileFunc() +// GetConfigFileC3 indicates an expected call of GetConfigFileC3. +func (mr *MockConfluentCurrentMockRecorder) GetConfigFileC3(service any) *MockConfluentCurrentGetConfigFileC3Call { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetConfigFileC3", reflect.TypeOf((*MockConfluentCurrent)(nil).GetConfigFileC3), service) + return &MockConfluentCurrentGetConfigFileC3Call{Call: call} } -// RemoveTrackingFileCalled returns true if RemoveTrackingFile was called at least once. -func (m *MockConfluentCurrent) RemoveTrackingFileCalled() bool { - m.lockRemoveTrackingFile.Lock() - defer m.lockRemoveTrackingFile.Unlock() +// MockConfluentCurrentGetConfigFileC3Call wrap *gomock.Call +type MockConfluentCurrentGetConfigFileC3Call struct { + *gomock.Call +} - return len(m.calls.RemoveTrackingFile) > 0 +// Return rewrite *gomock.Call.Return +func (c *MockConfluentCurrentGetConfigFileC3Call) Return(arg0 string, arg1 error) *MockConfluentCurrentGetConfigFileC3Call { + c.Call = c.Call.Return(arg0, arg1) + return c } -// RemoveTrackingFileCalls returns the calls made to RemoveTrackingFile. -func (m *MockConfluentCurrent) RemoveTrackingFileCalls() []struct { -} { - m.lockRemoveTrackingFile.Lock() - defer m.lockRemoveTrackingFile.Unlock() +// Do rewrite *gomock.Call.Do +func (c *MockConfluentCurrentGetConfigFileC3Call) Do(f func(string) (string, error)) *MockConfluentCurrentGetConfigFileC3Call { + c.Call = c.Call.Do(f) + return c +} - return m.calls.RemoveTrackingFile +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockConfluentCurrentGetConfigFileC3Call) DoAndReturn(f func(string) (string, error)) *MockConfluentCurrentGetConfigFileC3Call { + c.Call = c.Call.DoAndReturn(f) + return c } -// GetCurrentDir mocks base method by wrapping the associated func. +// GetCurrentDir mocks base method. func (m *MockConfluentCurrent) GetCurrentDir() (string, error) { - m.lockGetCurrentDir.Lock() - defer m.lockGetCurrentDir.Unlock() - - if m.GetCurrentDirFunc == nil { - panic("mocker: MockConfluentCurrent.GetCurrentDirFunc is nil but MockConfluentCurrent.GetCurrentDir was called.") - } - - call := struct { - }{} - - m.calls.GetCurrentDir = append(m.calls.GetCurrentDir, call) - - return m.GetCurrentDirFunc() + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCurrentDir") + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 } -// GetCurrentDirCalled returns true if GetCurrentDir was called at least once. -func (m *MockConfluentCurrent) GetCurrentDirCalled() bool { - m.lockGetCurrentDir.Lock() - defer m.lockGetCurrentDir.Unlock() - - return len(m.calls.GetCurrentDir) > 0 +// GetCurrentDir indicates an expected call of GetCurrentDir. +func (mr *MockConfluentCurrentMockRecorder) GetCurrentDir() *MockConfluentCurrentGetCurrentDirCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCurrentDir", reflect.TypeOf((*MockConfluentCurrent)(nil).GetCurrentDir)) + return &MockConfluentCurrentGetCurrentDirCall{Call: call} } -// GetCurrentDirCalls returns the calls made to GetCurrentDir. -func (m *MockConfluentCurrent) GetCurrentDirCalls() []struct { -} { - m.lockGetCurrentDir.Lock() - defer m.lockGetCurrentDir.Unlock() - - return m.calls.GetCurrentDir +// MockConfluentCurrentGetCurrentDirCall wrap *gomock.Call +type MockConfluentCurrentGetCurrentDirCall struct { + *gomock.Call } -// RemoveCurrentDir mocks base method by wrapping the associated func. -func (m *MockConfluentCurrent) RemoveCurrentDir() error { - m.lockRemoveCurrentDir.Lock() - defer m.lockRemoveCurrentDir.Unlock() - - if m.RemoveCurrentDirFunc == nil { - panic("mocker: MockConfluentCurrent.RemoveCurrentDirFunc is nil but MockConfluentCurrent.RemoveCurrentDir was called.") - } - - call := struct { - }{} - - m.calls.RemoveCurrentDir = append(m.calls.RemoveCurrentDir, call) - - return m.RemoveCurrentDirFunc() +// Return rewrite *gomock.Call.Return +func (c *MockConfluentCurrentGetCurrentDirCall) Return(arg0 string, arg1 error) *MockConfluentCurrentGetCurrentDirCall { + c.Call = c.Call.Return(arg0, arg1) + return c } -// RemoveCurrentDirCalled returns true if RemoveCurrentDir was called at least once. -func (m *MockConfluentCurrent) RemoveCurrentDirCalled() bool { - m.lockRemoveCurrentDir.Lock() - defer m.lockRemoveCurrentDir.Unlock() - - return len(m.calls.RemoveCurrentDir) > 0 +// Do rewrite *gomock.Call.Do +func (c *MockConfluentCurrentGetCurrentDirCall) Do(f func() (string, error)) *MockConfluentCurrentGetCurrentDirCall { + c.Call = c.Call.Do(f) + return c } -// RemoveCurrentDirCalls returns the calls made to RemoveCurrentDir. -func (m *MockConfluentCurrent) RemoveCurrentDirCalls() []struct { -} { - m.lockRemoveCurrentDir.Lock() - defer m.lockRemoveCurrentDir.Unlock() - - return m.calls.RemoveCurrentDir +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockConfluentCurrentGetCurrentDirCall) DoAndReturn(f func() (string, error)) *MockConfluentCurrentGetCurrentDirCall { + c.Call = c.Call.DoAndReturn(f) + return c } -// GetDataDir mocks base method by wrapping the associated func. +// GetDataDir mocks base method. func (m *MockConfluentCurrent) GetDataDir(service string) (string, error) { - m.lockGetDataDir.Lock() - defer m.lockGetDataDir.Unlock() - - if m.GetDataDirFunc == nil { - panic("mocker: MockConfluentCurrent.GetDataDirFunc is nil but MockConfluentCurrent.GetDataDir was called.") - } - - call := struct { - Service string - }{ - Service: service, - } - - m.calls.GetDataDir = append(m.calls.GetDataDir, call) + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetDataDir", service) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} - return m.GetDataDirFunc(service) +// GetDataDir indicates an expected call of GetDataDir. +func (mr *MockConfluentCurrentMockRecorder) GetDataDir(service any) *MockConfluentCurrentGetDataDirCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDataDir", reflect.TypeOf((*MockConfluentCurrent)(nil).GetDataDir), service) + return &MockConfluentCurrentGetDataDirCall{Call: call} } -// GetDataDirCalled returns true if GetDataDir was called at least once. -func (m *MockConfluentCurrent) GetDataDirCalled() bool { - m.lockGetDataDir.Lock() - defer m.lockGetDataDir.Unlock() +// MockConfluentCurrentGetDataDirCall wrap *gomock.Call +type MockConfluentCurrentGetDataDirCall struct { + *gomock.Call +} - return len(m.calls.GetDataDir) > 0 +// Return rewrite *gomock.Call.Return +func (c *MockConfluentCurrentGetDataDirCall) Return(arg0 string, arg1 error) *MockConfluentCurrentGetDataDirCall { + c.Call = c.Call.Return(arg0, arg1) + return c } -// GetDataDirCalls returns the calls made to GetDataDir. -func (m *MockConfluentCurrent) GetDataDirCalls() []struct { - Service string -} { - m.lockGetDataDir.Lock() - defer m.lockGetDataDir.Unlock() +// Do rewrite *gomock.Call.Do +func (c *MockConfluentCurrentGetDataDirCall) Do(f func(string) (string, error)) *MockConfluentCurrentGetDataDirCall { + c.Call = c.Call.Do(f) + return c +} - return m.calls.GetDataDir +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockConfluentCurrentGetDataDirCall) DoAndReturn(f func(string) (string, error)) *MockConfluentCurrentGetDataDirCall { + c.Call = c.Call.DoAndReturn(f) + return c } -// GetLogsDir mocks base method by wrapping the associated func. -func (m *MockConfluentCurrent) GetLogsDir(service string) (string, error) { - m.lockGetLogsDir.Lock() - defer m.lockGetLogsDir.Unlock() +// GetLogFile mocks base method. +func (m *MockConfluentCurrent) GetLogFile(service string) (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetLogFile", service) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} - if m.GetLogsDirFunc == nil { - panic("mocker: MockConfluentCurrent.GetLogsDirFunc is nil but MockConfluentCurrent.GetLogsDir was called.") - } +// GetLogFile indicates an expected call of GetLogFile. +func (mr *MockConfluentCurrentMockRecorder) GetLogFile(service any) *MockConfluentCurrentGetLogFileCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLogFile", reflect.TypeOf((*MockConfluentCurrent)(nil).GetLogFile), service) + return &MockConfluentCurrentGetLogFileCall{Call: call} +} - call := struct { - Service string - }{ - Service: service, - } +// MockConfluentCurrentGetLogFileCall wrap *gomock.Call +type MockConfluentCurrentGetLogFileCall struct { + *gomock.Call +} - m.calls.GetLogsDir = append(m.calls.GetLogsDir, call) +// Return rewrite *gomock.Call.Return +func (c *MockConfluentCurrentGetLogFileCall) Return(arg0 string, arg1 error) *MockConfluentCurrentGetLogFileCall { + c.Call = c.Call.Return(arg0, arg1) + return c +} - return m.GetLogsDirFunc(service) +// Do rewrite *gomock.Call.Do +func (c *MockConfluentCurrentGetLogFileCall) Do(f func(string) (string, error)) *MockConfluentCurrentGetLogFileCall { + c.Call = c.Call.Do(f) + return c } -// GetLogsDirCalled returns true if GetLogsDir was called at least once. -func (m *MockConfluentCurrent) GetLogsDirCalled() bool { - m.lockGetLogsDir.Lock() - defer m.lockGetLogsDir.Unlock() +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockConfluentCurrentGetLogFileCall) DoAndReturn(f func(string) (string, error)) *MockConfluentCurrentGetLogFileCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - return len(m.calls.GetLogsDir) > 0 +// GetLogsDir mocks base method. +func (m *MockConfluentCurrent) GetLogsDir(service string) (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetLogsDir", service) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 } -// GetLogsDirCalls returns the calls made to GetLogsDir. -func (m *MockConfluentCurrent) GetLogsDirCalls() []struct { - Service string -} { - m.lockGetLogsDir.Lock() - defer m.lockGetLogsDir.Unlock() +// GetLogsDir indicates an expected call of GetLogsDir. +func (mr *MockConfluentCurrentMockRecorder) GetLogsDir(service any) *MockConfluentCurrentGetLogsDirCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLogsDir", reflect.TypeOf((*MockConfluentCurrent)(nil).GetLogsDir), service) + return &MockConfluentCurrentGetLogsDirCall{Call: call} +} - return m.calls.GetLogsDir +// MockConfluentCurrentGetLogsDirCall wrap *gomock.Call +type MockConfluentCurrentGetLogsDirCall struct { + *gomock.Call } -// GetConfigFile mocks base method by wrapping the associated func. -func (m *MockConfluentCurrent) GetConfigFile(service string) (string, error) { - m.lockGetConfigFile.Lock() - defer m.lockGetConfigFile.Unlock() +// Return rewrite *gomock.Call.Return +func (c *MockConfluentCurrentGetLogsDirCall) Return(arg0 string, arg1 error) *MockConfluentCurrentGetLogsDirCall { + c.Call = c.Call.Return(arg0, arg1) + return c +} - if m.GetConfigFileFunc == nil { - panic("mocker: MockConfluentCurrent.GetConfigFileFunc is nil but MockConfluentCurrent.GetConfigFile was called.") - } +// Do rewrite *gomock.Call.Do +func (c *MockConfluentCurrentGetLogsDirCall) Do(f func(string) (string, error)) *MockConfluentCurrentGetLogsDirCall { + c.Call = c.Call.Do(f) + return c +} - call := struct { - Service string - }{ - Service: service, - } +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockConfluentCurrentGetLogsDirCall) DoAndReturn(f func(string) (string, error)) *MockConfluentCurrentGetLogsDirCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - m.calls.GetConfigFile = append(m.calls.GetConfigFile, call) +// GetPidFile mocks base method. +func (m *MockConfluentCurrent) GetPidFile(service string) (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetPidFile", service) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} - return m.GetConfigFileFunc(service) +// GetPidFile indicates an expected call of GetPidFile. +func (mr *MockConfluentCurrentMockRecorder) GetPidFile(service any) *MockConfluentCurrentGetPidFileCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPidFile", reflect.TypeOf((*MockConfluentCurrent)(nil).GetPidFile), service) + return &MockConfluentCurrentGetPidFileCall{Call: call} } -// GetConfigFileCalled returns true if GetConfigFile was called at least once. -func (m *MockConfluentCurrent) GetConfigFileCalled() bool { - m.lockGetConfigFile.Lock() - defer m.lockGetConfigFile.Unlock() +// MockConfluentCurrentGetPidFileCall wrap *gomock.Call +type MockConfluentCurrentGetPidFileCall struct { + *gomock.Call +} - return len(m.calls.GetConfigFile) > 0 +// Return rewrite *gomock.Call.Return +func (c *MockConfluentCurrentGetPidFileCall) Return(arg0 string, arg1 error) *MockConfluentCurrentGetPidFileCall { + c.Call = c.Call.Return(arg0, arg1) + return c } -// GetConfigFileCalls returns the calls made to GetConfigFile. -func (m *MockConfluentCurrent) GetConfigFileCalls() []struct { - Service string -} { - m.lockGetConfigFile.Lock() - defer m.lockGetConfigFile.Unlock() +// Do rewrite *gomock.Call.Do +func (c *MockConfluentCurrentGetPidFileCall) Do(f func(string) (string, error)) *MockConfluentCurrentGetPidFileCall { + c.Call = c.Call.Do(f) + return c +} - return m.calls.GetConfigFile +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockConfluentCurrentGetPidFileCall) DoAndReturn(f func(string) (string, error)) *MockConfluentCurrentGetPidFileCall { + c.Call = c.Call.DoAndReturn(f) + return c } -// WriteConfig mocks base method by wrapping the associated func. -func (m *MockConfluentCurrent) WriteConfig(service string, config []byte) error { - m.lockWriteConfig.Lock() - defer m.lockWriteConfig.Unlock() +// HasLogFile mocks base method. +func (m *MockConfluentCurrent) HasLogFile(service string) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "HasLogFile", service) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} - if m.WriteConfigFunc == nil { - panic("mocker: MockConfluentCurrent.WriteConfigFunc is nil but MockConfluentCurrent.WriteConfig was called.") - } +// HasLogFile indicates an expected call of HasLogFile. +func (mr *MockConfluentCurrentMockRecorder) HasLogFile(service any) *MockConfluentCurrentHasLogFileCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasLogFile", reflect.TypeOf((*MockConfluentCurrent)(nil).HasLogFile), service) + return &MockConfluentCurrentHasLogFileCall{Call: call} +} - call := struct { - Service string - Config []byte - }{ - Service: service, - Config: config, - } +// MockConfluentCurrentHasLogFileCall wrap *gomock.Call +type MockConfluentCurrentHasLogFileCall struct { + *gomock.Call +} - m.calls.WriteConfig = append(m.calls.WriteConfig, call) +// Return rewrite *gomock.Call.Return +func (c *MockConfluentCurrentHasLogFileCall) Return(arg0 bool, arg1 error) *MockConfluentCurrentHasLogFileCall { + c.Call = c.Call.Return(arg0, arg1) + return c +} - return m.WriteConfigFunc(service, config) +// Do rewrite *gomock.Call.Do +func (c *MockConfluentCurrentHasLogFileCall) Do(f func(string) (bool, error)) *MockConfluentCurrentHasLogFileCall { + c.Call = c.Call.Do(f) + return c } -// WriteConfigCalled returns true if WriteConfig was called at least once. -func (m *MockConfluentCurrent) WriteConfigCalled() bool { - m.lockWriteConfig.Lock() - defer m.lockWriteConfig.Unlock() +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockConfluentCurrentHasLogFileCall) DoAndReturn(f func(string) (bool, error)) *MockConfluentCurrentHasLogFileCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - return len(m.calls.WriteConfig) > 0 +// HasPidFile mocks base method. +func (m *MockConfluentCurrent) HasPidFile(service string) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "HasPidFile", service) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 } -// WriteConfigCalls returns the calls made to WriteConfig. -func (m *MockConfluentCurrent) WriteConfigCalls() []struct { - Service string - Config []byte -} { - m.lockWriteConfig.Lock() - defer m.lockWriteConfig.Unlock() +// HasPidFile indicates an expected call of HasPidFile. +func (mr *MockConfluentCurrentMockRecorder) HasPidFile(service any) *MockConfluentCurrentHasPidFileCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasPidFile", reflect.TypeOf((*MockConfluentCurrent)(nil).HasPidFile), service) + return &MockConfluentCurrentHasPidFileCall{Call: call} +} - return m.calls.WriteConfig +// MockConfluentCurrentHasPidFileCall wrap *gomock.Call +type MockConfluentCurrentHasPidFileCall struct { + *gomock.Call } -// GetLogFile mocks base method by wrapping the associated func. -func (m *MockConfluentCurrent) GetLogFile(service string) (string, error) { - m.lockGetLogFile.Lock() - defer m.lockGetLogFile.Unlock() +// Return rewrite *gomock.Call.Return +func (c *MockConfluentCurrentHasPidFileCall) Return(arg0 bool, arg1 error) *MockConfluentCurrentHasPidFileCall { + c.Call = c.Call.Return(arg0, arg1) + return c +} - if m.GetLogFileFunc == nil { - panic("mocker: MockConfluentCurrent.GetLogFileFunc is nil but MockConfluentCurrent.GetLogFile was called.") - } +// Do rewrite *gomock.Call.Do +func (c *MockConfluentCurrentHasPidFileCall) Do(f func(string) (bool, error)) *MockConfluentCurrentHasPidFileCall { + c.Call = c.Call.Do(f) + return c +} - call := struct { - Service string - }{ - Service: service, - } +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockConfluentCurrentHasPidFileCall) DoAndReturn(f func(string) (bool, error)) *MockConfluentCurrentHasPidFileCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - m.calls.GetLogFile = append(m.calls.GetLogFile, call) +// HasTrackingFile mocks base method. +func (m *MockConfluentCurrent) HasTrackingFile() bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "HasTrackingFile") + ret0, _ := ret[0].(bool) + return ret0 +} - return m.GetLogFileFunc(service) +// HasTrackingFile indicates an expected call of HasTrackingFile. +func (mr *MockConfluentCurrentMockRecorder) HasTrackingFile() *MockConfluentCurrentHasTrackingFileCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasTrackingFile", reflect.TypeOf((*MockConfluentCurrent)(nil).HasTrackingFile)) + return &MockConfluentCurrentHasTrackingFileCall{Call: call} } -// GetLogFileCalled returns true if GetLogFile was called at least once. -func (m *MockConfluentCurrent) GetLogFileCalled() bool { - m.lockGetLogFile.Lock() - defer m.lockGetLogFile.Unlock() +// MockConfluentCurrentHasTrackingFileCall wrap *gomock.Call +type MockConfluentCurrentHasTrackingFileCall struct { + *gomock.Call +} - return len(m.calls.GetLogFile) > 0 +// Return rewrite *gomock.Call.Return +func (c *MockConfluentCurrentHasTrackingFileCall) Return(arg0 bool) *MockConfluentCurrentHasTrackingFileCall { + c.Call = c.Call.Return(arg0) + return c } -// GetLogFileCalls returns the calls made to GetLogFile. -func (m *MockConfluentCurrent) GetLogFileCalls() []struct { - Service string -} { - m.lockGetLogFile.Lock() - defer m.lockGetLogFile.Unlock() +// Do rewrite *gomock.Call.Do +func (c *MockConfluentCurrentHasTrackingFileCall) Do(f func() bool) *MockConfluentCurrentHasTrackingFileCall { + c.Call = c.Call.Do(f) + return c +} - return m.calls.GetLogFile +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockConfluentCurrentHasTrackingFileCall) DoAndReturn(f func() bool) *MockConfluentCurrentHasTrackingFileCall { + c.Call = c.Call.DoAndReturn(f) + return c } -// HasLogFile mocks base method by wrapping the associated func. -func (m *MockConfluentCurrent) HasLogFile(service string) (bool, error) { - m.lockHasLogFile.Lock() - defer m.lockHasLogFile.Unlock() +// ReadPid mocks base method. +func (m *MockConfluentCurrent) ReadPid(service string) (int, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReadPid", service) + ret0, _ := ret[0].(int) + ret1, _ := ret[1].(error) + return ret0, ret1 +} - if m.HasLogFileFunc == nil { - panic("mocker: MockConfluentCurrent.HasLogFileFunc is nil but MockConfluentCurrent.HasLogFile was called.") - } +// ReadPid indicates an expected call of ReadPid. +func (mr *MockConfluentCurrentMockRecorder) ReadPid(service any) *MockConfluentCurrentReadPidCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadPid", reflect.TypeOf((*MockConfluentCurrent)(nil).ReadPid), service) + return &MockConfluentCurrentReadPidCall{Call: call} +} - call := struct { - Service string - }{ - Service: service, - } +// MockConfluentCurrentReadPidCall wrap *gomock.Call +type MockConfluentCurrentReadPidCall struct { + *gomock.Call +} - m.calls.HasLogFile = append(m.calls.HasLogFile, call) +// Return rewrite *gomock.Call.Return +func (c *MockConfluentCurrentReadPidCall) Return(arg0 int, arg1 error) *MockConfluentCurrentReadPidCall { + c.Call = c.Call.Return(arg0, arg1) + return c +} - return m.HasLogFileFunc(service) +// Do rewrite *gomock.Call.Do +func (c *MockConfluentCurrentReadPidCall) Do(f func(string) (int, error)) *MockConfluentCurrentReadPidCall { + c.Call = c.Call.Do(f) + return c } -// HasLogFileCalled returns true if HasLogFile was called at least once. -func (m *MockConfluentCurrent) HasLogFileCalled() bool { - m.lockHasLogFile.Lock() - defer m.lockHasLogFile.Unlock() +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockConfluentCurrentReadPidCall) DoAndReturn(f func(string) (int, error)) *MockConfluentCurrentReadPidCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - return len(m.calls.HasLogFile) > 0 +// RemoveCurrentDir mocks base method. +func (m *MockConfluentCurrent) RemoveCurrentDir() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RemoveCurrentDir") + ret0, _ := ret[0].(error) + return ret0 } -// HasLogFileCalls returns the calls made to HasLogFile. -func (m *MockConfluentCurrent) HasLogFileCalls() []struct { - Service string -} { - m.lockHasLogFile.Lock() - defer m.lockHasLogFile.Unlock() +// RemoveCurrentDir indicates an expected call of RemoveCurrentDir. +func (mr *MockConfluentCurrentMockRecorder) RemoveCurrentDir() *MockConfluentCurrentRemoveCurrentDirCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveCurrentDir", reflect.TypeOf((*MockConfluentCurrent)(nil).RemoveCurrentDir)) + return &MockConfluentCurrentRemoveCurrentDirCall{Call: call} +} - return m.calls.HasLogFile +// MockConfluentCurrentRemoveCurrentDirCall wrap *gomock.Call +type MockConfluentCurrentRemoveCurrentDirCall struct { + *gomock.Call } -// GetPidFile mocks base method by wrapping the associated func. -func (m *MockConfluentCurrent) GetPidFile(service string) (string, error) { - m.lockGetPidFile.Lock() - defer m.lockGetPidFile.Unlock() +// Return rewrite *gomock.Call.Return +func (c *MockConfluentCurrentRemoveCurrentDirCall) Return(arg0 error) *MockConfluentCurrentRemoveCurrentDirCall { + c.Call = c.Call.Return(arg0) + return c +} - if m.GetPidFileFunc == nil { - panic("mocker: MockConfluentCurrent.GetPidFileFunc is nil but MockConfluentCurrent.GetPidFile was called.") - } +// Do rewrite *gomock.Call.Do +func (c *MockConfluentCurrentRemoveCurrentDirCall) Do(f func() error) *MockConfluentCurrentRemoveCurrentDirCall { + c.Call = c.Call.Do(f) + return c +} - call := struct { - Service string - }{ - Service: service, - } +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockConfluentCurrentRemoveCurrentDirCall) DoAndReturn(f func() error) *MockConfluentCurrentRemoveCurrentDirCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - m.calls.GetPidFile = append(m.calls.GetPidFile, call) +// RemovePidFile mocks base method. +func (m *MockConfluentCurrent) RemovePidFile(service string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RemovePidFile", service) + ret0, _ := ret[0].(error) + return ret0 +} - return m.GetPidFileFunc(service) +// RemovePidFile indicates an expected call of RemovePidFile. +func (mr *MockConfluentCurrentMockRecorder) RemovePidFile(service any) *MockConfluentCurrentRemovePidFileCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemovePidFile", reflect.TypeOf((*MockConfluentCurrent)(nil).RemovePidFile), service) + return &MockConfluentCurrentRemovePidFileCall{Call: call} } -// GetPidFileCalled returns true if GetPidFile was called at least once. -func (m *MockConfluentCurrent) GetPidFileCalled() bool { - m.lockGetPidFile.Lock() - defer m.lockGetPidFile.Unlock() +// MockConfluentCurrentRemovePidFileCall wrap *gomock.Call +type MockConfluentCurrentRemovePidFileCall struct { + *gomock.Call +} - return len(m.calls.GetPidFile) > 0 +// Return rewrite *gomock.Call.Return +func (c *MockConfluentCurrentRemovePidFileCall) Return(arg0 error) *MockConfluentCurrentRemovePidFileCall { + c.Call = c.Call.Return(arg0) + return c } -// GetPidFileCalls returns the calls made to GetPidFile. -func (m *MockConfluentCurrent) GetPidFileCalls() []struct { - Service string -} { - m.lockGetPidFile.Lock() - defer m.lockGetPidFile.Unlock() +// Do rewrite *gomock.Call.Do +func (c *MockConfluentCurrentRemovePidFileCall) Do(f func(string) error) *MockConfluentCurrentRemovePidFileCall { + c.Call = c.Call.Do(f) + return c +} - return m.calls.GetPidFile +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockConfluentCurrentRemovePidFileCall) DoAndReturn(f func(string) error) *MockConfluentCurrentRemovePidFileCall { + c.Call = c.Call.DoAndReturn(f) + return c } -// HasPidFile mocks base method by wrapping the associated func. -func (m *MockConfluentCurrent) HasPidFile(service string) (bool, error) { - m.lockHasPidFile.Lock() - defer m.lockHasPidFile.Unlock() +// RemoveTrackingFile mocks base method. +func (m *MockConfluentCurrent) RemoveTrackingFile() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RemoveTrackingFile") + ret0, _ := ret[0].(error) + return ret0 +} - if m.HasPidFileFunc == nil { - panic("mocker: MockConfluentCurrent.HasPidFileFunc is nil but MockConfluentCurrent.HasPidFile was called.") - } +// RemoveTrackingFile indicates an expected call of RemoveTrackingFile. +func (mr *MockConfluentCurrentMockRecorder) RemoveTrackingFile() *MockConfluentCurrentRemoveTrackingFileCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveTrackingFile", reflect.TypeOf((*MockConfluentCurrent)(nil).RemoveTrackingFile)) + return &MockConfluentCurrentRemoveTrackingFileCall{Call: call} +} - call := struct { - Service string - }{ - Service: service, - } +// MockConfluentCurrentRemoveTrackingFileCall wrap *gomock.Call +type MockConfluentCurrentRemoveTrackingFileCall struct { + *gomock.Call +} - m.calls.HasPidFile = append(m.calls.HasPidFile, call) +// Return rewrite *gomock.Call.Return +func (c *MockConfluentCurrentRemoveTrackingFileCall) Return(arg0 error) *MockConfluentCurrentRemoveTrackingFileCall { + c.Call = c.Call.Return(arg0) + return c +} - return m.HasPidFileFunc(service) +// Do rewrite *gomock.Call.Do +func (c *MockConfluentCurrentRemoveTrackingFileCall) Do(f func() error) *MockConfluentCurrentRemoveTrackingFileCall { + c.Call = c.Call.Do(f) + return c } -// HasPidFileCalled returns true if HasPidFile was called at least once. -func (m *MockConfluentCurrent) HasPidFileCalled() bool { - m.lockHasPidFile.Lock() - defer m.lockHasPidFile.Unlock() +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockConfluentCurrentRemoveTrackingFileCall) DoAndReturn(f func() error) *MockConfluentCurrentRemoveTrackingFileCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - return len(m.calls.HasPidFile) > 0 +// WriteConfig mocks base method. +func (m *MockConfluentCurrent) WriteConfig(service string, config []byte) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "WriteConfig", service, config) + ret0, _ := ret[0].(error) + return ret0 } -// HasPidFileCalls returns the calls made to HasPidFile. -func (m *MockConfluentCurrent) HasPidFileCalls() []struct { - Service string -} { - m.lockHasPidFile.Lock() - defer m.lockHasPidFile.Unlock() +// WriteConfig indicates an expected call of WriteConfig. +func (mr *MockConfluentCurrentMockRecorder) WriteConfig(service, config any) *MockConfluentCurrentWriteConfigCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteConfig", reflect.TypeOf((*MockConfluentCurrent)(nil).WriteConfig), service, config) + return &MockConfluentCurrentWriteConfigCall{Call: call} +} - return m.calls.HasPidFile +// MockConfluentCurrentWriteConfigCall wrap *gomock.Call +type MockConfluentCurrentWriteConfigCall struct { + *gomock.Call } -// ReadPid mocks base method by wrapping the associated func. -func (m *MockConfluentCurrent) ReadPid(service string) (int, error) { - m.lockReadPid.Lock() - defer m.lockReadPid.Unlock() +// Return rewrite *gomock.Call.Return +func (c *MockConfluentCurrentWriteConfigCall) Return(arg0 error) *MockConfluentCurrentWriteConfigCall { + c.Call = c.Call.Return(arg0) + return c +} - if m.ReadPidFunc == nil { - panic("mocker: MockConfluentCurrent.ReadPidFunc is nil but MockConfluentCurrent.ReadPid was called.") - } +// Do rewrite *gomock.Call.Do +func (c *MockConfluentCurrentWriteConfigCall) Do(f func(string, []byte) error) *MockConfluentCurrentWriteConfigCall { + c.Call = c.Call.Do(f) + return c +} - call := struct { - Service string - }{ - Service: service, - } +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockConfluentCurrentWriteConfigCall) DoAndReturn(f func(string, []byte) error) *MockConfluentCurrentWriteConfigCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - m.calls.ReadPid = append(m.calls.ReadPid, call) +// WriteConfigC3 mocks base method. +func (m *MockConfluentCurrent) WriteConfigC3(service string, config []byte) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "WriteConfigC3", service, config) + ret0, _ := ret[0].(error) + return ret0 +} - return m.ReadPidFunc(service) +// WriteConfigC3 indicates an expected call of WriteConfigC3. +func (mr *MockConfluentCurrentMockRecorder) WriteConfigC3(service, config any) *MockConfluentCurrentWriteConfigC3Call { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteConfigC3", reflect.TypeOf((*MockConfluentCurrent)(nil).WriteConfigC3), service, config) + return &MockConfluentCurrentWriteConfigC3Call{Call: call} } -// ReadPidCalled returns true if ReadPid was called at least once. -func (m *MockConfluentCurrent) ReadPidCalled() bool { - m.lockReadPid.Lock() - defer m.lockReadPid.Unlock() +// MockConfluentCurrentWriteConfigC3Call wrap *gomock.Call +type MockConfluentCurrentWriteConfigC3Call struct { + *gomock.Call +} - return len(m.calls.ReadPid) > 0 +// Return rewrite *gomock.Call.Return +func (c *MockConfluentCurrentWriteConfigC3Call) Return(arg0 error) *MockConfluentCurrentWriteConfigC3Call { + c.Call = c.Call.Return(arg0) + return c } -// ReadPidCalls returns the calls made to ReadPid. -func (m *MockConfluentCurrent) ReadPidCalls() []struct { - Service string -} { - m.lockReadPid.Lock() - defer m.lockReadPid.Unlock() +// Do rewrite *gomock.Call.Do +func (c *MockConfluentCurrentWriteConfigC3Call) Do(f func(string, []byte) error) *MockConfluentCurrentWriteConfigC3Call { + c.Call = c.Call.Do(f) + return c +} - return m.calls.ReadPid +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockConfluentCurrentWriteConfigC3Call) DoAndReturn(f func(string, []byte) error) *MockConfluentCurrentWriteConfigC3Call { + c.Call = c.Call.DoAndReturn(f) + return c } -// WritePid mocks base method by wrapping the associated func. +// WritePid mocks base method. func (m *MockConfluentCurrent) WritePid(service string, pid int) error { - m.lockWritePid.Lock() - defer m.lockWritePid.Unlock() - - if m.WritePidFunc == nil { - panic("mocker: MockConfluentCurrent.WritePidFunc is nil but MockConfluentCurrent.WritePid was called.") - } - - call := struct { - Service string - Pid int - }{ - Service: service, - Pid: pid, - } - - m.calls.WritePid = append(m.calls.WritePid, call) - - return m.WritePidFunc(service, pid) + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "WritePid", service, pid) + ret0, _ := ret[0].(error) + return ret0 } -// WritePidCalled returns true if WritePid was called at least once. -func (m *MockConfluentCurrent) WritePidCalled() bool { - m.lockWritePid.Lock() - defer m.lockWritePid.Unlock() +// WritePid indicates an expected call of WritePid. +func (mr *MockConfluentCurrentMockRecorder) WritePid(service, pid any) *MockConfluentCurrentWritePidCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WritePid", reflect.TypeOf((*MockConfluentCurrent)(nil).WritePid), service, pid) + return &MockConfluentCurrentWritePidCall{Call: call} +} - return len(m.calls.WritePid) > 0 +// MockConfluentCurrentWritePidCall wrap *gomock.Call +type MockConfluentCurrentWritePidCall struct { + *gomock.Call } -// WritePidCalls returns the calls made to WritePid. -func (m *MockConfluentCurrent) WritePidCalls() []struct { - Service string - Pid int -} { - m.lockWritePid.Lock() - defer m.lockWritePid.Unlock() +// Return rewrite *gomock.Call.Return +func (c *MockConfluentCurrentWritePidCall) Return(arg0 error) *MockConfluentCurrentWritePidCall { + c.Call = c.Call.Return(arg0) + return c +} - return m.calls.WritePid +// Do rewrite *gomock.Call.Do +func (c *MockConfluentCurrentWritePidCall) Do(f func(string, int) error) *MockConfluentCurrentWritePidCall { + c.Call = c.Call.Do(f) + return c } -// RemovePidFile mocks base method by wrapping the associated func. -func (m *MockConfluentCurrent) RemovePidFile(service string) error { - m.lockRemovePidFile.Lock() - defer m.lockRemovePidFile.Unlock() - - if m.RemovePidFileFunc == nil { - panic("mocker: MockConfluentCurrent.RemovePidFileFunc is nil but MockConfluentCurrent.RemovePidFile was called.") - } - - call := struct { - Service string - }{ - Service: service, - } - - m.calls.RemovePidFile = append(m.calls.RemovePidFile, call) - - return m.RemovePidFileFunc(service) -} - -// RemovePidFileCalled returns true if RemovePidFile was called at least once. -func (m *MockConfluentCurrent) RemovePidFileCalled() bool { - m.lockRemovePidFile.Lock() - defer m.lockRemovePidFile.Unlock() - - return len(m.calls.RemovePidFile) > 0 -} - -// RemovePidFileCalls returns the calls made to RemovePidFile. -func (m *MockConfluentCurrent) RemovePidFileCalls() []struct { - Service string -} { - m.lockRemovePidFile.Lock() - defer m.lockRemovePidFile.Unlock() - - return m.calls.RemovePidFile -} - -// Reset resets the calls made to the mocked methods. -func (m *MockConfluentCurrent) Reset() { - m.lockHasTrackingFile.Lock() - m.calls.HasTrackingFile = nil - m.lockHasTrackingFile.Unlock() - m.lockRemoveTrackingFile.Lock() - m.calls.RemoveTrackingFile = nil - m.lockRemoveTrackingFile.Unlock() - m.lockGetCurrentDir.Lock() - m.calls.GetCurrentDir = nil - m.lockGetCurrentDir.Unlock() - m.lockRemoveCurrentDir.Lock() - m.calls.RemoveCurrentDir = nil - m.lockRemoveCurrentDir.Unlock() - m.lockGetDataDir.Lock() - m.calls.GetDataDir = nil - m.lockGetDataDir.Unlock() - m.lockGetLogsDir.Lock() - m.calls.GetLogsDir = nil - m.lockGetLogsDir.Unlock() - m.lockGetConfigFile.Lock() - m.calls.GetConfigFile = nil - m.lockGetConfigFile.Unlock() - m.lockWriteConfig.Lock() - m.calls.WriteConfig = nil - m.lockWriteConfig.Unlock() - m.lockGetLogFile.Lock() - m.calls.GetLogFile = nil - m.lockGetLogFile.Unlock() - m.lockHasLogFile.Lock() - m.calls.HasLogFile = nil - m.lockHasLogFile.Unlock() - m.lockGetPidFile.Lock() - m.calls.GetPidFile = nil - m.lockGetPidFile.Unlock() - m.lockHasPidFile.Lock() - m.calls.HasPidFile = nil - m.lockHasPidFile.Unlock() - m.lockReadPid.Lock() - m.calls.ReadPid = nil - m.lockReadPid.Unlock() - m.lockWritePid.Lock() - m.calls.WritePid = nil - m.lockWritePid.Unlock() - m.lockRemovePidFile.Lock() - m.calls.RemovePidFile = nil - m.lockRemovePidFile.Unlock() +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockConfluentCurrentWritePidCall) DoAndReturn(f func(string, int) error) *MockConfluentCurrentWritePidCall { + c.Call = c.Call.DoAndReturn(f) + return c } diff --git a/mock/confluent_home.go b/mock/confluent_home.go index 724c650873..1d192e3219 100644 --- a/mock/confluent_home.go +++ b/mock/confluent_home.go @@ -1,593 +1,516 @@ -// Code generated by mocker. DO NOT EDIT. -// github.com/travisjeffery/mocker -// Source: pkg/local/confluent_home.go - +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/confluentinc/cli/v4/pkg/local (interfaces: ConfluentHome) +// +// Generated by this command: +// +// mockgen -typed -destination=../../mock/confluent_home.go -package=mock github.com/confluentinc/cli/v4/pkg/local ConfluentHome +// + +// Package mock is a generated GoMock package. package mock import ( - sync "sync" + reflect "reflect" + + gomock "go.uber.org/mock/gomock" ) -// MockConfluentHome is a mock of ConfluentHome interface +// MockConfluentHome is a mock of ConfluentHome interface. type MockConfluentHome struct { - lockGetFile sync.Mutex - GetFileFunc func(path ...string) (string, error) - - lockHasFile sync.Mutex - HasFileFunc func(path ...string) (bool, error) - - lockFindFile sync.Mutex - FindFileFunc func(pattern string) ([]string, error) - - lockIsConfluentPlatform sync.Mutex - IsConfluentPlatformFunc func() (bool, error) - - lockGetConfluentVersion sync.Mutex - GetConfluentVersionFunc func() (string, error) - - lockIsAtLeastVersion sync.Mutex - IsAtLeastVersionFunc func(targetVersion string) (bool, error) - - lockGetServiceScript sync.Mutex - GetServiceScriptFunc func(action, service string) (string, error) - - lockReadServiceConfig sync.Mutex - ReadServiceConfigFunc func(service string, zookeeperMode bool) ([]byte, error) - - lockReadServicePort sync.Mutex - ReadServicePortFunc func(service string, zookeeperMode bool) (int, error) - - lockGetVersion sync.Mutex - GetVersionFunc func(service string, zookeeperMode bool) (string, error) - - lockGetConnectorConfigFile sync.Mutex - GetConnectorConfigFileFunc func(connector string) (string, error) - - lockGetKafkaScript sync.Mutex - GetKafkaScriptFunc func(mode, format string) (string, error) - - calls struct { - GetFile []struct { - Path []string - } - HasFile []struct { - Path []string - } - FindFile []struct { - Pattern string - } - IsConfluentPlatform []struct { - } - GetConfluentVersion []struct { - } - IsAtLeastVersion []struct { - TargetVersion string - } - GetServiceScript []struct { - Action string - Service string - } - ReadServiceConfig []struct { - Service string - ZookeeperMode bool - } - ReadServicePort []struct { - Service string - ZookeeperMode bool - } - GetVersion []struct { - Service string - ZookeeperMode bool - } - GetConnectorConfigFile []struct { - Connector string - } - GetKafkaScript []struct { - Mode string - Format string - } - } + ctrl *gomock.Controller + recorder *MockConfluentHomeMockRecorder + isgomock struct{} } -// GetFile mocks base method by wrapping the associated func. -func (m *MockConfluentHome) GetFile(path ...string) (string, error) { - m.lockGetFile.Lock() - defer m.lockGetFile.Unlock() - - if m.GetFileFunc == nil { - panic("mocker: MockConfluentHome.GetFileFunc is nil but MockConfluentHome.GetFile was called.") - } - - call := struct { - Path []string - }{ - Path: path, - } - - m.calls.GetFile = append(m.calls.GetFile, call) - - return m.GetFileFunc(path...) +// MockConfluentHomeMockRecorder is the mock recorder for MockConfluentHome. +type MockConfluentHomeMockRecorder struct { + mock *MockConfluentHome } -// GetFileCalled returns true if GetFile was called at least once. -func (m *MockConfluentHome) GetFileCalled() bool { - m.lockGetFile.Lock() - defer m.lockGetFile.Unlock() - - return len(m.calls.GetFile) > 0 +// NewMockConfluentHome creates a new mock instance. +func NewMockConfluentHome(ctrl *gomock.Controller) *MockConfluentHome { + mock := &MockConfluentHome{ctrl: ctrl} + mock.recorder = &MockConfluentHomeMockRecorder{mock} + return mock } -// GetFileCalls returns the calls made to GetFile. -func (m *MockConfluentHome) GetFileCalls() []struct { - Path []string -} { - m.lockGetFile.Lock() - defer m.lockGetFile.Unlock() - - return m.calls.GetFile +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockConfluentHome) EXPECT() *MockConfluentHomeMockRecorder { + return m.recorder } -// HasFile mocks base method by wrapping the associated func. -func (m *MockConfluentHome) HasFile(path ...string) (bool, error) { - m.lockHasFile.Lock() - defer m.lockHasFile.Unlock() - - if m.HasFileFunc == nil { - panic("mocker: MockConfluentHome.HasFileFunc is nil but MockConfluentHome.HasFile was called.") - } - - call := struct { - Path []string - }{ - Path: path, - } - - m.calls.HasFile = append(m.calls.HasFile, call) - - return m.HasFileFunc(path...) +// FindFile mocks base method. +func (m *MockConfluentHome) FindFile(pattern string) ([]string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "FindFile", pattern) + ret0, _ := ret[0].([]string) + ret1, _ := ret[1].(error) + return ret0, ret1 } -// HasFileCalled returns true if HasFile was called at least once. -func (m *MockConfluentHome) HasFileCalled() bool { - m.lockHasFile.Lock() - defer m.lockHasFile.Unlock() - - return len(m.calls.HasFile) > 0 +// FindFile indicates an expected call of FindFile. +func (mr *MockConfluentHomeMockRecorder) FindFile(pattern any) *MockConfluentHomeFindFileCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindFile", reflect.TypeOf((*MockConfluentHome)(nil).FindFile), pattern) + return &MockConfluentHomeFindFileCall{Call: call} } -// HasFileCalls returns the calls made to HasFile. -func (m *MockConfluentHome) HasFileCalls() []struct { - Path []string -} { - m.lockHasFile.Lock() - defer m.lockHasFile.Unlock() - - return m.calls.HasFile +// MockConfluentHomeFindFileCall wrap *gomock.Call +type MockConfluentHomeFindFileCall struct { + *gomock.Call } -// FindFile mocks base method by wrapping the associated func. -func (m *MockConfluentHome) FindFile(pattern string) ([]string, error) { - m.lockFindFile.Lock() - defer m.lockFindFile.Unlock() - - if m.FindFileFunc == nil { - panic("mocker: MockConfluentHome.FindFileFunc is nil but MockConfluentHome.FindFile was called.") - } - - call := struct { - Pattern string - }{ - Pattern: pattern, - } - - m.calls.FindFile = append(m.calls.FindFile, call) - - return m.FindFileFunc(pattern) +// Return rewrite *gomock.Call.Return +func (c *MockConfluentHomeFindFileCall) Return(arg0 []string, arg1 error) *MockConfluentHomeFindFileCall { + c.Call = c.Call.Return(arg0, arg1) + return c } -// FindFileCalled returns true if FindFile was called at least once. -func (m *MockConfluentHome) FindFileCalled() bool { - m.lockFindFile.Lock() - defer m.lockFindFile.Unlock() +// Do rewrite *gomock.Call.Do +func (c *MockConfluentHomeFindFileCall) Do(f func(string) ([]string, error)) *MockConfluentHomeFindFileCall { + c.Call = c.Call.Do(f) + return c +} - return len(m.calls.FindFile) > 0 +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockConfluentHomeFindFileCall) DoAndReturn(f func(string) ([]string, error)) *MockConfluentHomeFindFileCall { + c.Call = c.Call.DoAndReturn(f) + return c } -// FindFileCalls returns the calls made to FindFile. -func (m *MockConfluentHome) FindFileCalls() []struct { - Pattern string -} { - m.lockFindFile.Lock() - defer m.lockFindFile.Unlock() +// GetConfluentVersion mocks base method. +func (m *MockConfluentHome) GetConfluentVersion() (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetConfluentVersion") + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} - return m.calls.FindFile +// GetConfluentVersion indicates an expected call of GetConfluentVersion. +func (mr *MockConfluentHomeMockRecorder) GetConfluentVersion() *MockConfluentHomeGetConfluentVersionCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetConfluentVersion", reflect.TypeOf((*MockConfluentHome)(nil).GetConfluentVersion)) + return &MockConfluentHomeGetConfluentVersionCall{Call: call} } -// IsConfluentPlatform mocks base method by wrapping the associated func. -func (m *MockConfluentHome) IsConfluentPlatform() (bool, error) { - m.lockIsConfluentPlatform.Lock() - defer m.lockIsConfluentPlatform.Unlock() +// MockConfluentHomeGetConfluentVersionCall wrap *gomock.Call +type MockConfluentHomeGetConfluentVersionCall struct { + *gomock.Call +} - if m.IsConfluentPlatformFunc == nil { - panic("mocker: MockConfluentHome.IsConfluentPlatformFunc is nil but MockConfluentHome.IsConfluentPlatform was called.") - } +// Return rewrite *gomock.Call.Return +func (c *MockConfluentHomeGetConfluentVersionCall) Return(arg0 string, arg1 error) *MockConfluentHomeGetConfluentVersionCall { + c.Call = c.Call.Return(arg0, arg1) + return c +} - call := struct { - }{} +// Do rewrite *gomock.Call.Do +func (c *MockConfluentHomeGetConfluentVersionCall) Do(f func() (string, error)) *MockConfluentHomeGetConfluentVersionCall { + c.Call = c.Call.Do(f) + return c +} - m.calls.IsConfluentPlatform = append(m.calls.IsConfluentPlatform, call) +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockConfluentHomeGetConfluentVersionCall) DoAndReturn(f func() (string, error)) *MockConfluentHomeGetConfluentVersionCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - return m.IsConfluentPlatformFunc() +// GetConnectorConfigFile mocks base method. +func (m *MockConfluentHome) GetConnectorConfigFile(connector string) (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetConnectorConfigFile", connector) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 } -// IsConfluentPlatformCalled returns true if IsConfluentPlatform was called at least once. -func (m *MockConfluentHome) IsConfluentPlatformCalled() bool { - m.lockIsConfluentPlatform.Lock() - defer m.lockIsConfluentPlatform.Unlock() +// GetConnectorConfigFile indicates an expected call of GetConnectorConfigFile. +func (mr *MockConfluentHomeMockRecorder) GetConnectorConfigFile(connector any) *MockConfluentHomeGetConnectorConfigFileCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetConnectorConfigFile", reflect.TypeOf((*MockConfluentHome)(nil).GetConnectorConfigFile), connector) + return &MockConfluentHomeGetConnectorConfigFileCall{Call: call} +} - return len(m.calls.IsConfluentPlatform) > 0 +// MockConfluentHomeGetConnectorConfigFileCall wrap *gomock.Call +type MockConfluentHomeGetConnectorConfigFileCall struct { + *gomock.Call } -// IsConfluentPlatformCalls returns the calls made to IsConfluentPlatform. -func (m *MockConfluentHome) IsConfluentPlatformCalls() []struct { -} { - m.lockIsConfluentPlatform.Lock() - defer m.lockIsConfluentPlatform.Unlock() +// Return rewrite *gomock.Call.Return +func (c *MockConfluentHomeGetConnectorConfigFileCall) Return(arg0 string, arg1 error) *MockConfluentHomeGetConnectorConfigFileCall { + c.Call = c.Call.Return(arg0, arg1) + return c +} - return m.calls.IsConfluentPlatform +// Do rewrite *gomock.Call.Do +func (c *MockConfluentHomeGetConnectorConfigFileCall) Do(f func(string) (string, error)) *MockConfluentHomeGetConnectorConfigFileCall { + c.Call = c.Call.Do(f) + return c } -// GetConfluentVersion mocks base method by wrapping the associated func. -func (m *MockConfluentHome) GetConfluentVersion() (string, error) { - m.lockGetConfluentVersion.Lock() - defer m.lockGetConfluentVersion.Unlock() +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockConfluentHomeGetConnectorConfigFileCall) DoAndReturn(f func(string) (string, error)) *MockConfluentHomeGetConnectorConfigFileCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - if m.GetConfluentVersionFunc == nil { - panic("mocker: MockConfluentHome.GetConfluentVersionFunc is nil but MockConfluentHome.GetConfluentVersion was called.") +// GetFile mocks base method. +func (m *MockConfluentHome) GetFile(path ...string) (string, error) { + m.ctrl.T.Helper() + varargs := []any{} + for _, a := range path { + varargs = append(varargs, a) } - - call := struct { - }{} - - m.calls.GetConfluentVersion = append(m.calls.GetConfluentVersion, call) - - return m.GetConfluentVersionFunc() + ret := m.ctrl.Call(m, "GetFile", varargs...) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 } -// GetConfluentVersionCalled returns true if GetConfluentVersion was called at least once. -func (m *MockConfluentHome) GetConfluentVersionCalled() bool { - m.lockGetConfluentVersion.Lock() - defer m.lockGetConfluentVersion.Unlock() - - return len(m.calls.GetConfluentVersion) > 0 +// GetFile indicates an expected call of GetFile. +func (mr *MockConfluentHomeMockRecorder) GetFile(path ...any) *MockConfluentHomeGetFileCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetFile", reflect.TypeOf((*MockConfluentHome)(nil).GetFile), path...) + return &MockConfluentHomeGetFileCall{Call: call} } -// GetConfluentVersionCalls returns the calls made to GetConfluentVersion. -func (m *MockConfluentHome) GetConfluentVersionCalls() []struct { -} { - m.lockGetConfluentVersion.Lock() - defer m.lockGetConfluentVersion.Unlock() - - return m.calls.GetConfluentVersion +// MockConfluentHomeGetFileCall wrap *gomock.Call +type MockConfluentHomeGetFileCall struct { + *gomock.Call } -// IsAtLeastVersion mocks base method by wrapping the associated func. -func (m *MockConfluentHome) IsAtLeastVersion(targetVersion string) (bool, error) { - m.lockIsAtLeastVersion.Lock() - defer m.lockIsAtLeastVersion.Unlock() +// Return rewrite *gomock.Call.Return +func (c *MockConfluentHomeGetFileCall) Return(arg0 string, arg1 error) *MockConfluentHomeGetFileCall { + c.Call = c.Call.Return(arg0, arg1) + return c +} - if m.IsAtLeastVersionFunc == nil { - panic("mocker: MockConfluentHome.IsAtLeastVersionFunc is nil but MockConfluentHome.IsAtLeastVersion was called.") - } +// Do rewrite *gomock.Call.Do +func (c *MockConfluentHomeGetFileCall) Do(f func(...string) (string, error)) *MockConfluentHomeGetFileCall { + c.Call = c.Call.Do(f) + return c +} - call := struct { - TargetVersion string - }{ - TargetVersion: targetVersion, - } +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockConfluentHomeGetFileCall) DoAndReturn(f func(...string) (string, error)) *MockConfluentHomeGetFileCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - m.calls.IsAtLeastVersion = append(m.calls.IsAtLeastVersion, call) +// GetKafkaScript mocks base method. +func (m *MockConfluentHome) GetKafkaScript(mode, format string) (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetKafkaScript", mode, format) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} - return m.IsAtLeastVersionFunc(targetVersion) +// GetKafkaScript indicates an expected call of GetKafkaScript. +func (mr *MockConfluentHomeMockRecorder) GetKafkaScript(mode, format any) *MockConfluentHomeGetKafkaScriptCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetKafkaScript", reflect.TypeOf((*MockConfluentHome)(nil).GetKafkaScript), mode, format) + return &MockConfluentHomeGetKafkaScriptCall{Call: call} } -// IsAtLeastVersionCalled returns true if IsAtLeastVersion was called at least once. -func (m *MockConfluentHome) IsAtLeastVersionCalled() bool { - m.lockIsAtLeastVersion.Lock() - defer m.lockIsAtLeastVersion.Unlock() +// MockConfluentHomeGetKafkaScriptCall wrap *gomock.Call +type MockConfluentHomeGetKafkaScriptCall struct { + *gomock.Call +} - return len(m.calls.IsAtLeastVersion) > 0 +// Return rewrite *gomock.Call.Return +func (c *MockConfluentHomeGetKafkaScriptCall) Return(arg0 string, arg1 error) *MockConfluentHomeGetKafkaScriptCall { + c.Call = c.Call.Return(arg0, arg1) + return c } -// IsAtLeastVersionCalls returns the calls made to IsAtLeastVersion. -func (m *MockConfluentHome) IsAtLeastVersionCalls() []struct { - TargetVersion string -} { - m.lockIsAtLeastVersion.Lock() - defer m.lockIsAtLeastVersion.Unlock() +// Do rewrite *gomock.Call.Do +func (c *MockConfluentHomeGetKafkaScriptCall) Do(f func(string, string) (string, error)) *MockConfluentHomeGetKafkaScriptCall { + c.Call = c.Call.Do(f) + return c +} - return m.calls.IsAtLeastVersion +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockConfluentHomeGetKafkaScriptCall) DoAndReturn(f func(string, string) (string, error)) *MockConfluentHomeGetKafkaScriptCall { + c.Call = c.Call.DoAndReturn(f) + return c } -// GetServiceScript mocks base method by wrapping the associated func. +// GetServiceScript mocks base method. func (m *MockConfluentHome) GetServiceScript(action, service string) (string, error) { - m.lockGetServiceScript.Lock() - defer m.lockGetServiceScript.Unlock() - - if m.GetServiceScriptFunc == nil { - panic("mocker: MockConfluentHome.GetServiceScriptFunc is nil but MockConfluentHome.GetServiceScript was called.") - } - - call := struct { - Action string - Service string - }{ - Action: action, - Service: service, - } - - m.calls.GetServiceScript = append(m.calls.GetServiceScript, call) - - return m.GetServiceScriptFunc(action, service) + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetServiceScript", action, service) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 } -// GetServiceScriptCalled returns true if GetServiceScript was called at least once. -func (m *MockConfluentHome) GetServiceScriptCalled() bool { - m.lockGetServiceScript.Lock() - defer m.lockGetServiceScript.Unlock() - - return len(m.calls.GetServiceScript) > 0 +// GetServiceScript indicates an expected call of GetServiceScript. +func (mr *MockConfluentHomeMockRecorder) GetServiceScript(action, service any) *MockConfluentHomeGetServiceScriptCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetServiceScript", reflect.TypeOf((*MockConfluentHome)(nil).GetServiceScript), action, service) + return &MockConfluentHomeGetServiceScriptCall{Call: call} } -// GetServiceScriptCalls returns the calls made to GetServiceScript. -func (m *MockConfluentHome) GetServiceScriptCalls() []struct { - Action string - Service string -} { - m.lockGetServiceScript.Lock() - defer m.lockGetServiceScript.Unlock() - - return m.calls.GetServiceScript +// MockConfluentHomeGetServiceScriptCall wrap *gomock.Call +type MockConfluentHomeGetServiceScriptCall struct { + *gomock.Call } -// ReadServiceConfig mocks base method by wrapping the associated func. -func (m *MockConfluentHome) ReadServiceConfig(service string, zookeeperMode bool) ([]byte, error) { - m.lockReadServiceConfig.Lock() - defer m.lockReadServiceConfig.Unlock() - - if m.ReadServiceConfigFunc == nil { - panic("mocker: MockConfluentHome.ReadServiceConfigFunc is nil but MockConfluentHome.ReadServiceConfig was called.") - } +// Return rewrite *gomock.Call.Return +func (c *MockConfluentHomeGetServiceScriptCall) Return(arg0 string, arg1 error) *MockConfluentHomeGetServiceScriptCall { + c.Call = c.Call.Return(arg0, arg1) + return c +} - call := struct { - Service string - ZookeeperMode bool - }{ - Service: service, - ZookeeperMode: zookeeperMode, - } +// Do rewrite *gomock.Call.Do +func (c *MockConfluentHomeGetServiceScriptCall) Do(f func(string, string) (string, error)) *MockConfluentHomeGetServiceScriptCall { + c.Call = c.Call.Do(f) + return c +} - m.calls.ReadServiceConfig = append(m.calls.ReadServiceConfig, call) +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockConfluentHomeGetServiceScriptCall) DoAndReturn(f func(string, string) (string, error)) *MockConfluentHomeGetServiceScriptCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - return m.ReadServiceConfigFunc(service, zookeeperMode) +// GetVersion mocks base method. +func (m *MockConfluentHome) GetVersion(service string, zookeeperMode bool) (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetVersion", service, zookeeperMode) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 } -// ReadServiceConfigCalled returns true if ReadServiceConfig was called at least once. -func (m *MockConfluentHome) ReadServiceConfigCalled() bool { - m.lockReadServiceConfig.Lock() - defer m.lockReadServiceConfig.Unlock() +// GetVersion indicates an expected call of GetVersion. +func (mr *MockConfluentHomeMockRecorder) GetVersion(service, zookeeperMode any) *MockConfluentHomeGetVersionCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVersion", reflect.TypeOf((*MockConfluentHome)(nil).GetVersion), service, zookeeperMode) + return &MockConfluentHomeGetVersionCall{Call: call} +} - return len(m.calls.ReadServiceConfig) > 0 +// MockConfluentHomeGetVersionCall wrap *gomock.Call +type MockConfluentHomeGetVersionCall struct { + *gomock.Call } -// ReadServiceConfigCalls returns the calls made to ReadServiceConfig. -func (m *MockConfluentHome) ReadServiceConfigCalls() []struct { - Service string - ZookeeperMode bool -} { - m.lockReadServiceConfig.Lock() - defer m.lockReadServiceConfig.Unlock() +// Return rewrite *gomock.Call.Return +func (c *MockConfluentHomeGetVersionCall) Return(arg0 string, arg1 error) *MockConfluentHomeGetVersionCall { + c.Call = c.Call.Return(arg0, arg1) + return c +} - return m.calls.ReadServiceConfig +// Do rewrite *gomock.Call.Do +func (c *MockConfluentHomeGetVersionCall) Do(f func(string, bool) (string, error)) *MockConfluentHomeGetVersionCall { + c.Call = c.Call.Do(f) + return c } -// ReadServicePort mocks base method by wrapping the associated func. -func (m *MockConfluentHome) ReadServicePort(service string, zookeeperMode bool) (int, error) { - m.lockReadServicePort.Lock() - defer m.lockReadServicePort.Unlock() +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockConfluentHomeGetVersionCall) DoAndReturn(f func(string, bool) (string, error)) *MockConfluentHomeGetVersionCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - if m.ReadServicePortFunc == nil { - panic("mocker: MockConfluentHome.ReadServicePortFunc is nil but MockConfluentHome.ReadServicePort was called.") +// HasFile mocks base method. +func (m *MockConfluentHome) HasFile(path ...string) (bool, error) { + m.ctrl.T.Helper() + varargs := []any{} + for _, a := range path { + varargs = append(varargs, a) } + ret := m.ctrl.Call(m, "HasFile", varargs...) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} - call := struct { - Service string - ZookeeperMode bool - }{ - Service: service, - ZookeeperMode: zookeeperMode, - } +// HasFile indicates an expected call of HasFile. +func (mr *MockConfluentHomeMockRecorder) HasFile(path ...any) *MockConfluentHomeHasFileCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasFile", reflect.TypeOf((*MockConfluentHome)(nil).HasFile), path...) + return &MockConfluentHomeHasFileCall{Call: call} +} - m.calls.ReadServicePort = append(m.calls.ReadServicePort, call) +// MockConfluentHomeHasFileCall wrap *gomock.Call +type MockConfluentHomeHasFileCall struct { + *gomock.Call +} - return m.ReadServicePortFunc(service, zookeeperMode) +// Return rewrite *gomock.Call.Return +func (c *MockConfluentHomeHasFileCall) Return(arg0 bool, arg1 error) *MockConfluentHomeHasFileCall { + c.Call = c.Call.Return(arg0, arg1) + return c } -// ReadServicePortCalled returns true if ReadServicePort was called at least once. -func (m *MockConfluentHome) ReadServicePortCalled() bool { - m.lockReadServicePort.Lock() - defer m.lockReadServicePort.Unlock() +// Do rewrite *gomock.Call.Do +func (c *MockConfluentHomeHasFileCall) Do(f func(...string) (bool, error)) *MockConfluentHomeHasFileCall { + c.Call = c.Call.Do(f) + return c +} - return len(m.calls.ReadServicePort) > 0 +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockConfluentHomeHasFileCall) DoAndReturn(f func(...string) (bool, error)) *MockConfluentHomeHasFileCall { + c.Call = c.Call.DoAndReturn(f) + return c } -// ReadServicePortCalls returns the calls made to ReadServicePort. -func (m *MockConfluentHome) ReadServicePortCalls() []struct { - Service string - ZookeeperMode bool -} { - m.lockReadServicePort.Lock() - defer m.lockReadServicePort.Unlock() +// IsAtLeastVersion mocks base method. +func (m *MockConfluentHome) IsAtLeastVersion(targetVersion string) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsAtLeastVersion", targetVersion) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} - return m.calls.ReadServicePort +// IsAtLeastVersion indicates an expected call of IsAtLeastVersion. +func (mr *MockConfluentHomeMockRecorder) IsAtLeastVersion(targetVersion any) *MockConfluentHomeIsAtLeastVersionCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsAtLeastVersion", reflect.TypeOf((*MockConfluentHome)(nil).IsAtLeastVersion), targetVersion) + return &MockConfluentHomeIsAtLeastVersionCall{Call: call} } -// GetVersion mocks base method by wrapping the associated func. -func (m *MockConfluentHome) GetVersion(service string, zookeeperMode bool) (string, error) { - m.lockGetVersion.Lock() - defer m.lockGetVersion.Unlock() +// MockConfluentHomeIsAtLeastVersionCall wrap *gomock.Call +type MockConfluentHomeIsAtLeastVersionCall struct { + *gomock.Call +} - if m.GetVersionFunc == nil { - panic("mocker: MockConfluentHome.GetVersionFunc is nil but MockConfluentHome.GetVersion was called.") - } +// Return rewrite *gomock.Call.Return +func (c *MockConfluentHomeIsAtLeastVersionCall) Return(arg0 bool, arg1 error) *MockConfluentHomeIsAtLeastVersionCall { + c.Call = c.Call.Return(arg0, arg1) + return c +} - call := struct { - Service string - ZookeeperMode bool - }{ - Service: service, - ZookeeperMode: zookeeperMode, - } +// Do rewrite *gomock.Call.Do +func (c *MockConfluentHomeIsAtLeastVersionCall) Do(f func(string) (bool, error)) *MockConfluentHomeIsAtLeastVersionCall { + c.Call = c.Call.Do(f) + return c +} - m.calls.GetVersion = append(m.calls.GetVersion, call) +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockConfluentHomeIsAtLeastVersionCall) DoAndReturn(f func(string) (bool, error)) *MockConfluentHomeIsAtLeastVersionCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - return m.GetVersionFunc(service, zookeeperMode) +// IsConfluentPlatform mocks base method. +func (m *MockConfluentHome) IsConfluentPlatform() (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsConfluentPlatform") + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 } -// GetVersionCalled returns true if GetVersion was called at least once. -func (m *MockConfluentHome) GetVersionCalled() bool { - m.lockGetVersion.Lock() - defer m.lockGetVersion.Unlock() +// IsConfluentPlatform indicates an expected call of IsConfluentPlatform. +func (mr *MockConfluentHomeMockRecorder) IsConfluentPlatform() *MockConfluentHomeIsConfluentPlatformCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsConfluentPlatform", reflect.TypeOf((*MockConfluentHome)(nil).IsConfluentPlatform)) + return &MockConfluentHomeIsConfluentPlatformCall{Call: call} +} - return len(m.calls.GetVersion) > 0 +// MockConfluentHomeIsConfluentPlatformCall wrap *gomock.Call +type MockConfluentHomeIsConfluentPlatformCall struct { + *gomock.Call } -// GetVersionCalls returns the calls made to GetVersion. -func (m *MockConfluentHome) GetVersionCalls() []struct { - Service string - ZookeeperMode bool -} { - m.lockGetVersion.Lock() - defer m.lockGetVersion.Unlock() +// Return rewrite *gomock.Call.Return +func (c *MockConfluentHomeIsConfluentPlatformCall) Return(arg0 bool, arg1 error) *MockConfluentHomeIsConfluentPlatformCall { + c.Call = c.Call.Return(arg0, arg1) + return c +} - return m.calls.GetVersion +// Do rewrite *gomock.Call.Do +func (c *MockConfluentHomeIsConfluentPlatformCall) Do(f func() (bool, error)) *MockConfluentHomeIsConfluentPlatformCall { + c.Call = c.Call.Do(f) + return c } -// GetConnectorConfigFile mocks base method by wrapping the associated func. -func (m *MockConfluentHome) GetConnectorConfigFile(connector string) (string, error) { - m.lockGetConnectorConfigFile.Lock() - defer m.lockGetConnectorConfigFile.Unlock() +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockConfluentHomeIsConfluentPlatformCall) DoAndReturn(f func() (bool, error)) *MockConfluentHomeIsConfluentPlatformCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - if m.GetConnectorConfigFileFunc == nil { - panic("mocker: MockConfluentHome.GetConnectorConfigFileFunc is nil but MockConfluentHome.GetConnectorConfigFile was called.") - } +// ReadServiceConfig mocks base method. +func (m *MockConfluentHome) ReadServiceConfig(service string, zookeeperMode bool) ([]byte, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReadServiceConfig", service, zookeeperMode) + ret0, _ := ret[0].([]byte) + ret1, _ := ret[1].(error) + return ret0, ret1 +} - call := struct { - Connector string - }{ - Connector: connector, - } +// ReadServiceConfig indicates an expected call of ReadServiceConfig. +func (mr *MockConfluentHomeMockRecorder) ReadServiceConfig(service, zookeeperMode any) *MockConfluentHomeReadServiceConfigCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadServiceConfig", reflect.TypeOf((*MockConfluentHome)(nil).ReadServiceConfig), service, zookeeperMode) + return &MockConfluentHomeReadServiceConfigCall{Call: call} +} - m.calls.GetConnectorConfigFile = append(m.calls.GetConnectorConfigFile, call) +// MockConfluentHomeReadServiceConfigCall wrap *gomock.Call +type MockConfluentHomeReadServiceConfigCall struct { + *gomock.Call +} - return m.GetConnectorConfigFileFunc(connector) +// Return rewrite *gomock.Call.Return +func (c *MockConfluentHomeReadServiceConfigCall) Return(arg0 []byte, arg1 error) *MockConfluentHomeReadServiceConfigCall { + c.Call = c.Call.Return(arg0, arg1) + return c } -// GetConnectorConfigFileCalled returns true if GetConnectorConfigFile was called at least once. -func (m *MockConfluentHome) GetConnectorConfigFileCalled() bool { - m.lockGetConnectorConfigFile.Lock() - defer m.lockGetConnectorConfigFile.Unlock() +// Do rewrite *gomock.Call.Do +func (c *MockConfluentHomeReadServiceConfigCall) Do(f func(string, bool) ([]byte, error)) *MockConfluentHomeReadServiceConfigCall { + c.Call = c.Call.Do(f) + return c +} - return len(m.calls.GetConnectorConfigFile) > 0 +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockConfluentHomeReadServiceConfigCall) DoAndReturn(f func(string, bool) ([]byte, error)) *MockConfluentHomeReadServiceConfigCall { + c.Call = c.Call.DoAndReturn(f) + return c } -// GetConnectorConfigFileCalls returns the calls made to GetConnectorConfigFile. -func (m *MockConfluentHome) GetConnectorConfigFileCalls() []struct { - Connector string -} { - m.lockGetConnectorConfigFile.Lock() - defer m.lockGetConnectorConfigFile.Unlock() +// ReadServicePort mocks base method. +func (m *MockConfluentHome) ReadServicePort(service string, zookeeperMode bool) (int, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReadServicePort", service, zookeeperMode) + ret0, _ := ret[0].(int) + ret1, _ := ret[1].(error) + return ret0, ret1 +} - return m.calls.GetConnectorConfigFile +// ReadServicePort indicates an expected call of ReadServicePort. +func (mr *MockConfluentHomeMockRecorder) ReadServicePort(service, zookeeperMode any) *MockConfluentHomeReadServicePortCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadServicePort", reflect.TypeOf((*MockConfluentHome)(nil).ReadServicePort), service, zookeeperMode) + return &MockConfluentHomeReadServicePortCall{Call: call} } -// GetKafkaScript mocks base method by wrapping the associated func. -func (m *MockConfluentHome) GetKafkaScript(mode, format string) (string, error) { - m.lockGetKafkaScript.Lock() - defer m.lockGetKafkaScript.Unlock() +// MockConfluentHomeReadServicePortCall wrap *gomock.Call +type MockConfluentHomeReadServicePortCall struct { + *gomock.Call +} - if m.GetKafkaScriptFunc == nil { - panic("mocker: MockConfluentHome.GetKafkaScriptFunc is nil but MockConfluentHome.GetKafkaScript was called.") - } +// Return rewrite *gomock.Call.Return +func (c *MockConfluentHomeReadServicePortCall) Return(arg0 int, arg1 error) *MockConfluentHomeReadServicePortCall { + c.Call = c.Call.Return(arg0, arg1) + return c +} - call := struct { - Mode string - Format string - }{ - Mode: mode, - Format: format, - } +// Do rewrite *gomock.Call.Do +func (c *MockConfluentHomeReadServicePortCall) Do(f func(string, bool) (int, error)) *MockConfluentHomeReadServicePortCall { + c.Call = c.Call.Do(f) + return c +} - m.calls.GetKafkaScript = append(m.calls.GetKafkaScript, call) - - return m.GetKafkaScriptFunc(mode, format) -} - -// GetKafkaScriptCalled returns true if GetKafkaScript was called at least once. -func (m *MockConfluentHome) GetKafkaScriptCalled() bool { - m.lockGetKafkaScript.Lock() - defer m.lockGetKafkaScript.Unlock() - - return len(m.calls.GetKafkaScript) > 0 -} - -// GetKafkaScriptCalls returns the calls made to GetKafkaScript. -func (m *MockConfluentHome) GetKafkaScriptCalls() []struct { - Mode string - Format string -} { - m.lockGetKafkaScript.Lock() - defer m.lockGetKafkaScript.Unlock() - - return m.calls.GetKafkaScript -} - -// Reset resets the calls made to the mocked methods. -func (m *MockConfluentHome) Reset() { - m.lockGetFile.Lock() - m.calls.GetFile = nil - m.lockGetFile.Unlock() - m.lockHasFile.Lock() - m.calls.HasFile = nil - m.lockHasFile.Unlock() - m.lockFindFile.Lock() - m.calls.FindFile = nil - m.lockFindFile.Unlock() - m.lockIsConfluentPlatform.Lock() - m.calls.IsConfluentPlatform = nil - m.lockIsConfluentPlatform.Unlock() - m.lockGetConfluentVersion.Lock() - m.calls.GetConfluentVersion = nil - m.lockGetConfluentVersion.Unlock() - m.lockIsAtLeastVersion.Lock() - m.calls.IsAtLeastVersion = nil - m.lockIsAtLeastVersion.Unlock() - m.lockGetServiceScript.Lock() - m.calls.GetServiceScript = nil - m.lockGetServiceScript.Unlock() - m.lockReadServiceConfig.Lock() - m.calls.ReadServiceConfig = nil - m.lockReadServiceConfig.Unlock() - m.lockReadServicePort.Lock() - m.calls.ReadServicePort = nil - m.lockReadServicePort.Unlock() - m.lockGetVersion.Lock() - m.calls.GetVersion = nil - m.lockGetVersion.Unlock() - m.lockGetConnectorConfigFile.Lock() - m.calls.GetConnectorConfigFile = nil - m.lockGetConnectorConfigFile.Unlock() - m.lockGetKafkaScript.Lock() - m.calls.GetKafkaScript = nil - m.lockGetKafkaScript.Unlock() +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockConfluentHomeReadServicePortCall) DoAndReturn(f func(string, bool) (int, error)) *MockConfluentHomeReadServicePortCall { + c.Call = c.Call.DoAndReturn(f) + return c } diff --git a/mock/login_credentials_manager.go b/mock/login_credentials_manager.go index ad59765cac..a814959d8d 100644 --- a/mock/login_credentials_manager.go +++ b/mock/login_credentials_manager.go @@ -1,604 +1,497 @@ -// Code generated by mocker. DO NOT EDIT. -// github.com/travisjeffery/mocker -// Source: pkg/auth/login_credentials_manager.go - +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/confluentinc/cli/v4/pkg/auth (interfaces: LoginCredentialsManager) +// +// Generated by this command: +// +// mockgen -typed -destination=../../mock/login_credentials_manager.go -package=mock github.com/confluentinc/cli/v4/pkg/auth LoginCredentialsManager +// + +// Package mock is a generated GoMock package. package mock import ( - sync "sync" + reflect "reflect" - github_com_confluentinc_ccloud_sdk_go_v1_public "github.com/confluentinc/ccloud-sdk-go-v1-public" - github_com_confluentinc_cli_v4_pkg_auth "github.com/confluentinc/cli/v4/pkg/auth" - github_com_confluentinc_cli_v4_pkg_config "github.com/confluentinc/cli/v4/pkg/config" + ccloud "github.com/confluentinc/ccloud-sdk-go-v1-public" + auth "github.com/confluentinc/cli/v4/pkg/auth" + config "github.com/confluentinc/cli/v4/pkg/config" + gomock "go.uber.org/mock/gomock" ) -// LoginCredentialsManager is a mock of LoginCredentialsManager interface -type LoginCredentialsManager struct { - lockGetCloudCredentialsFromEnvVar sync.Mutex - GetCloudCredentialsFromEnvVarFunc func(arg0 string) func() (*github_com_confluentinc_cli_v4_pkg_auth.Credentials, error) - - lockGetOnPremCredentialsFromEnvVar sync.Mutex - GetOnPremCredentialsFromEnvVarFunc func() func() (*github_com_confluentinc_cli_v4_pkg_auth.Credentials, error) - - lockGetCredentialsFromConfig sync.Mutex - GetCredentialsFromConfigFunc func(arg0 *github_com_confluentinc_cli_v4_pkg_config.Config, arg1 github_com_confluentinc_cli_v4_pkg_config.MachineParams) func() (*github_com_confluentinc_cli_v4_pkg_auth.Credentials, error) - - lockGetCredentialsFromKeychain sync.Mutex - GetCredentialsFromKeychainFunc func(arg0 bool, arg1, arg2 string) func() (*github_com_confluentinc_cli_v4_pkg_auth.Credentials, error) - - lockGetOnPremSsoCredentials sync.Mutex - GetOnPremSsoCredentialsFunc func(url, caCertPath, clientCertPath, clientKeyPath string, unsafeTrace bool) func() (*github_com_confluentinc_cli_v4_pkg_auth.Credentials, error) - - lockGetOnPremSsoCredentialsFromConfig sync.Mutex - GetOnPremSsoCredentialsFromConfigFunc func(arg0 *github_com_confluentinc_cli_v4_pkg_config.Config, arg1 bool) func() (*github_com_confluentinc_cli_v4_pkg_auth.Credentials, error) - - lockGetOnPremCertOnlyCredentials sync.Mutex - GetOnPremCertOnlyCredentialsFunc func(certificateOnly bool) func() (*github_com_confluentinc_cli_v4_pkg_auth.Credentials, error) - - lockGetCloudCredentialsFromPrompt sync.Mutex - GetCloudCredentialsFromPromptFunc func(arg0 string) func() (*github_com_confluentinc_cli_v4_pkg_auth.Credentials, error) - - lockGetOnPremCredentialsFromPrompt sync.Mutex - GetOnPremCredentialsFromPromptFunc func() func() (*github_com_confluentinc_cli_v4_pkg_auth.Credentials, error) - - lockGetPrerunCredentialsFromConfig sync.Mutex - GetPrerunCredentialsFromConfigFunc func(arg0 *github_com_confluentinc_cli_v4_pkg_config.Config) func() (*github_com_confluentinc_cli_v4_pkg_auth.Credentials, error) - - lockGetOnPremPrerunCredentialsFromEnvVar sync.Mutex - GetOnPremPrerunCredentialsFromEnvVarFunc func() func() (*github_com_confluentinc_cli_v4_pkg_auth.Credentials, error) - - lockSetCloudClient sync.Mutex - SetCloudClientFunc func(arg0 *github_com_confluentinc_ccloud_sdk_go_v1_public.Client) - - calls struct { - GetCloudCredentialsFromEnvVar []struct { - Arg0 string - } - GetOnPremCredentialsFromEnvVar []struct { - } - GetCredentialsFromConfig []struct { - Arg0 *github_com_confluentinc_cli_v4_pkg_config.Config - Arg1 github_com_confluentinc_cli_v4_pkg_config.MachineParams - } - GetCredentialsFromKeychain []struct { - Arg0 bool - Arg1 string - Arg2 string - } - GetOnPremSsoCredentials []struct { - Url string - CaCertPath string - ClientCertPath string - ClientKeyPath string - UnsafeTrace bool - } - GetOnPremSsoCredentialsFromConfig []struct { - Arg0 *github_com_confluentinc_cli_v4_pkg_config.Config - Arg1 bool - } - GetOnPremCertOnlyCredentials []struct { - CertificateOnly bool - } - GetCloudCredentialsFromPrompt []struct { - Arg0 string - } - GetOnPremCredentialsFromPrompt []struct { - } - GetPrerunCredentialsFromConfig []struct { - Arg0 *github_com_confluentinc_cli_v4_pkg_config.Config - } - GetOnPremPrerunCredentialsFromEnvVar []struct { - } - SetCloudClient []struct { - Arg0 *github_com_confluentinc_ccloud_sdk_go_v1_public.Client - } - } +// MockLoginCredentialsManager is a mock of LoginCredentialsManager interface. +type MockLoginCredentialsManager struct { + ctrl *gomock.Controller + recorder *MockLoginCredentialsManagerMockRecorder + isgomock struct{} } -// GetCloudCredentialsFromEnvVar mocks base method by wrapping the associated func. -func (m *LoginCredentialsManager) GetCloudCredentialsFromEnvVar(arg0 string) func() (*github_com_confluentinc_cli_v4_pkg_auth.Credentials, error) { - m.lockGetCloudCredentialsFromEnvVar.Lock() - defer m.lockGetCloudCredentialsFromEnvVar.Unlock() - - if m.GetCloudCredentialsFromEnvVarFunc == nil { - panic("mocker: LoginCredentialsManager.GetCloudCredentialsFromEnvVarFunc is nil but LoginCredentialsManager.GetCloudCredentialsFromEnvVar was called.") - } - - call := struct { - Arg0 string - }{ - Arg0: arg0, - } - - m.calls.GetCloudCredentialsFromEnvVar = append(m.calls.GetCloudCredentialsFromEnvVar, call) - - return m.GetCloudCredentialsFromEnvVarFunc(arg0) +// MockLoginCredentialsManagerMockRecorder is the mock recorder for MockLoginCredentialsManager. +type MockLoginCredentialsManagerMockRecorder struct { + mock *MockLoginCredentialsManager } -// GetCloudCredentialsFromEnvVarCalled returns true if GetCloudCredentialsFromEnvVar was called at least once. -func (m *LoginCredentialsManager) GetCloudCredentialsFromEnvVarCalled() bool { - m.lockGetCloudCredentialsFromEnvVar.Lock() - defer m.lockGetCloudCredentialsFromEnvVar.Unlock() - - return len(m.calls.GetCloudCredentialsFromEnvVar) > 0 +// NewMockLoginCredentialsManager creates a new mock instance. +func NewMockLoginCredentialsManager(ctrl *gomock.Controller) *MockLoginCredentialsManager { + mock := &MockLoginCredentialsManager{ctrl: ctrl} + mock.recorder = &MockLoginCredentialsManagerMockRecorder{mock} + return mock } -// GetCloudCredentialsFromEnvVarCalls returns the calls made to GetCloudCredentialsFromEnvVar. -func (m *LoginCredentialsManager) GetCloudCredentialsFromEnvVarCalls() []struct { - Arg0 string -} { - m.lockGetCloudCredentialsFromEnvVar.Lock() - defer m.lockGetCloudCredentialsFromEnvVar.Unlock() - - return m.calls.GetCloudCredentialsFromEnvVar +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockLoginCredentialsManager) EXPECT() *MockLoginCredentialsManagerMockRecorder { + return m.recorder } -// GetOnPremCredentialsFromEnvVar mocks base method by wrapping the associated func. -func (m *LoginCredentialsManager) GetOnPremCredentialsFromEnvVar() func() (*github_com_confluentinc_cli_v4_pkg_auth.Credentials, error) { - m.lockGetOnPremCredentialsFromEnvVar.Lock() - defer m.lockGetOnPremCredentialsFromEnvVar.Unlock() - - if m.GetOnPremCredentialsFromEnvVarFunc == nil { - panic("mocker: LoginCredentialsManager.GetOnPremCredentialsFromEnvVarFunc is nil but LoginCredentialsManager.GetOnPremCredentialsFromEnvVar was called.") - } - - call := struct { - }{} - - m.calls.GetOnPremCredentialsFromEnvVar = append(m.calls.GetOnPremCredentialsFromEnvVar, call) - - return m.GetOnPremCredentialsFromEnvVarFunc() -} - -// GetOnPremCredentialsFromEnvVarCalled returns true if GetOnPremCredentialsFromEnvVar was called at least once. -func (m *LoginCredentialsManager) GetOnPremCredentialsFromEnvVarCalled() bool { - m.lockGetOnPremCredentialsFromEnvVar.Lock() - defer m.lockGetOnPremCredentialsFromEnvVar.Unlock() - - return len(m.calls.GetOnPremCredentialsFromEnvVar) > 0 +// GetCloudCredentialsFromEnvVar mocks base method. +func (m *MockLoginCredentialsManager) GetCloudCredentialsFromEnvVar(arg0 string) func() (*auth.Credentials, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCloudCredentialsFromEnvVar", arg0) + ret0, _ := ret[0].(func() (*auth.Credentials, error)) + return ret0 } -// GetOnPremCredentialsFromEnvVarCalls returns the calls made to GetOnPremCredentialsFromEnvVar. -func (m *LoginCredentialsManager) GetOnPremCredentialsFromEnvVarCalls() []struct { -} { - m.lockGetOnPremCredentialsFromEnvVar.Lock() - defer m.lockGetOnPremCredentialsFromEnvVar.Unlock() - - return m.calls.GetOnPremCredentialsFromEnvVar +// GetCloudCredentialsFromEnvVar indicates an expected call of GetCloudCredentialsFromEnvVar. +func (mr *MockLoginCredentialsManagerMockRecorder) GetCloudCredentialsFromEnvVar(arg0 any) *MockLoginCredentialsManagerGetCloudCredentialsFromEnvVarCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCloudCredentialsFromEnvVar", reflect.TypeOf((*MockLoginCredentialsManager)(nil).GetCloudCredentialsFromEnvVar), arg0) + return &MockLoginCredentialsManagerGetCloudCredentialsFromEnvVarCall{Call: call} } -// GetCredentialsFromConfig mocks base method by wrapping the associated func. -func (m *LoginCredentialsManager) GetCredentialsFromConfig(arg0 *github_com_confluentinc_cli_v4_pkg_config.Config, arg1 github_com_confluentinc_cli_v4_pkg_config.MachineParams) func() (*github_com_confluentinc_cli_v4_pkg_auth.Credentials, error) { - m.lockGetCredentialsFromConfig.Lock() - defer m.lockGetCredentialsFromConfig.Unlock() - - if m.GetCredentialsFromConfigFunc == nil { - panic("mocker: LoginCredentialsManager.GetCredentialsFromConfigFunc is nil but LoginCredentialsManager.GetCredentialsFromConfig was called.") - } - - call := struct { - Arg0 *github_com_confluentinc_cli_v4_pkg_config.Config - Arg1 github_com_confluentinc_cli_v4_pkg_config.MachineParams - }{ - Arg0: arg0, - Arg1: arg1, - } - - m.calls.GetCredentialsFromConfig = append(m.calls.GetCredentialsFromConfig, call) - - return m.GetCredentialsFromConfigFunc(arg0, arg1) +// MockLoginCredentialsManagerGetCloudCredentialsFromEnvVarCall wrap *gomock.Call +type MockLoginCredentialsManagerGetCloudCredentialsFromEnvVarCall struct { + *gomock.Call } -// GetCredentialsFromConfigCalled returns true if GetCredentialsFromConfig was called at least once. -func (m *LoginCredentialsManager) GetCredentialsFromConfigCalled() bool { - m.lockGetCredentialsFromConfig.Lock() - defer m.lockGetCredentialsFromConfig.Unlock() - - return len(m.calls.GetCredentialsFromConfig) > 0 +// Return rewrite *gomock.Call.Return +func (c *MockLoginCredentialsManagerGetCloudCredentialsFromEnvVarCall) Return(arg0 func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetCloudCredentialsFromEnvVarCall { + c.Call = c.Call.Return(arg0) + return c } -// GetCredentialsFromConfigCalls returns the calls made to GetCredentialsFromConfig. -func (m *LoginCredentialsManager) GetCredentialsFromConfigCalls() []struct { - Arg0 *github_com_confluentinc_cli_v4_pkg_config.Config - Arg1 github_com_confluentinc_cli_v4_pkg_config.MachineParams -} { - m.lockGetCredentialsFromConfig.Lock() - defer m.lockGetCredentialsFromConfig.Unlock() - - return m.calls.GetCredentialsFromConfig +// Do rewrite *gomock.Call.Do +func (c *MockLoginCredentialsManagerGetCloudCredentialsFromEnvVarCall) Do(f func(string) func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetCloudCredentialsFromEnvVarCall { + c.Call = c.Call.Do(f) + return c } -// GetCredentialsFromKeychain mocks base method by wrapping the associated func. -func (m *LoginCredentialsManager) GetCredentialsFromKeychain(arg0 bool, arg1, arg2 string) func() (*github_com_confluentinc_cli_v4_pkg_auth.Credentials, error) { - m.lockGetCredentialsFromKeychain.Lock() - defer m.lockGetCredentialsFromKeychain.Unlock() - - if m.GetCredentialsFromKeychainFunc == nil { - panic("mocker: LoginCredentialsManager.GetCredentialsFromKeychainFunc is nil but LoginCredentialsManager.GetCredentialsFromKeychain was called.") - } - - call := struct { - Arg0 bool - Arg1 string - Arg2 string - }{ - Arg0: arg0, - Arg1: arg1, - Arg2: arg2, - } - - m.calls.GetCredentialsFromKeychain = append(m.calls.GetCredentialsFromKeychain, call) - - return m.GetCredentialsFromKeychainFunc(arg0, arg1, arg2) +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockLoginCredentialsManagerGetCloudCredentialsFromEnvVarCall) DoAndReturn(f func(string) func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetCloudCredentialsFromEnvVarCall { + c.Call = c.Call.DoAndReturn(f) + return c } -// GetCredentialsFromKeychainCalled returns true if GetCredentialsFromKeychain was called at least once. -func (m *LoginCredentialsManager) GetCredentialsFromKeychainCalled() bool { - m.lockGetCredentialsFromKeychain.Lock() - defer m.lockGetCredentialsFromKeychain.Unlock() - - return len(m.calls.GetCredentialsFromKeychain) > 0 +// GetCloudCredentialsFromPrompt mocks base method. +func (m *MockLoginCredentialsManager) GetCloudCredentialsFromPrompt(arg0 string) func() (*auth.Credentials, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCloudCredentialsFromPrompt", arg0) + ret0, _ := ret[0].(func() (*auth.Credentials, error)) + return ret0 } -// GetCredentialsFromKeychainCalls returns the calls made to GetCredentialsFromKeychain. -func (m *LoginCredentialsManager) GetCredentialsFromKeychainCalls() []struct { - Arg0 bool - Arg1 string - Arg2 string -} { - m.lockGetCredentialsFromKeychain.Lock() - defer m.lockGetCredentialsFromKeychain.Unlock() - - return m.calls.GetCredentialsFromKeychain +// GetCloudCredentialsFromPrompt indicates an expected call of GetCloudCredentialsFromPrompt. +func (mr *MockLoginCredentialsManagerMockRecorder) GetCloudCredentialsFromPrompt(arg0 any) *MockLoginCredentialsManagerGetCloudCredentialsFromPromptCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCloudCredentialsFromPrompt", reflect.TypeOf((*MockLoginCredentialsManager)(nil).GetCloudCredentialsFromPrompt), arg0) + return &MockLoginCredentialsManagerGetCloudCredentialsFromPromptCall{Call: call} } -// GetOnPremSsoCredentials mocks base method by wrapping the associated func. -func (m *LoginCredentialsManager) GetOnPremSsoCredentials(url, caCertPath, clientCertPath, clientKeyPath string, unsafeTrace bool) func() (*github_com_confluentinc_cli_v4_pkg_auth.Credentials, error) { - m.lockGetOnPremSsoCredentials.Lock() - defer m.lockGetOnPremSsoCredentials.Unlock() - - if m.GetOnPremSsoCredentialsFunc == nil { - panic("mocker: LoginCredentialsManager.GetOnPremSsoCredentialsFunc is nil but LoginCredentialsManager.GetOnPremSsoCredentials was called.") - } - - call := struct { - Url string - CaCertPath string - ClientCertPath string - ClientKeyPath string - UnsafeTrace bool - }{ - Url: url, - CaCertPath: caCertPath, - ClientCertPath: clientCertPath, - ClientKeyPath: clientKeyPath, - UnsafeTrace: unsafeTrace, - } - - m.calls.GetOnPremSsoCredentials = append(m.calls.GetOnPremSsoCredentials, call) - - return m.GetOnPremSsoCredentialsFunc(url, caCertPath, clientCertPath, clientKeyPath, unsafeTrace) +// MockLoginCredentialsManagerGetCloudCredentialsFromPromptCall wrap *gomock.Call +type MockLoginCredentialsManagerGetCloudCredentialsFromPromptCall struct { + *gomock.Call } -// GetOnPremSsoCredentialsCalled returns true if GetOnPremSsoCredentials was called at least once. -func (m *LoginCredentialsManager) GetOnPremSsoCredentialsCalled() bool { - m.lockGetOnPremSsoCredentials.Lock() - defer m.lockGetOnPremSsoCredentials.Unlock() - - return len(m.calls.GetOnPremSsoCredentials) > 0 +// Return rewrite *gomock.Call.Return +func (c *MockLoginCredentialsManagerGetCloudCredentialsFromPromptCall) Return(arg0 func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetCloudCredentialsFromPromptCall { + c.Call = c.Call.Return(arg0) + return c } -// GetOnPremSsoCredentialsCalls returns the calls made to GetOnPremSsoCredentials. -func (m *LoginCredentialsManager) GetOnPremSsoCredentialsCalls() []struct { - Url string - CaCertPath string - ClientCertPath string - ClientKeyPath string - UnsafeTrace bool -} { - m.lockGetOnPremSsoCredentials.Lock() - defer m.lockGetOnPremSsoCredentials.Unlock() - - return m.calls.GetOnPremSsoCredentials +// Do rewrite *gomock.Call.Do +func (c *MockLoginCredentialsManagerGetCloudCredentialsFromPromptCall) Do(f func(string) func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetCloudCredentialsFromPromptCall { + c.Call = c.Call.Do(f) + return c } -// GetOnPremSsoCredentialsFromConfig mocks base method by wrapping the associated func. -func (m *LoginCredentialsManager) GetOnPremSsoCredentialsFromConfig(arg0 *github_com_confluentinc_cli_v4_pkg_config.Config, arg1 bool) func() (*github_com_confluentinc_cli_v4_pkg_auth.Credentials, error) { - m.lockGetOnPremSsoCredentialsFromConfig.Lock() - defer m.lockGetOnPremSsoCredentialsFromConfig.Unlock() - - if m.GetOnPremSsoCredentialsFromConfigFunc == nil { - panic("mocker: LoginCredentialsManager.GetOnPremSsoCredentialsFromConfigFunc is nil but LoginCredentialsManager.GetOnPremSsoCredentialsFromConfig was called.") - } - - call := struct { - Arg0 *github_com_confluentinc_cli_v4_pkg_config.Config - Arg1 bool - }{ - Arg0: arg0, - Arg1: arg1, - } - - m.calls.GetOnPremSsoCredentialsFromConfig = append(m.calls.GetOnPremSsoCredentialsFromConfig, call) +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockLoginCredentialsManagerGetCloudCredentialsFromPromptCall) DoAndReturn(f func(string) func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetCloudCredentialsFromPromptCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - return m.GetOnPremSsoCredentialsFromConfigFunc(arg0, arg1) +// GetCredentialsFromConfig mocks base method. +func (m *MockLoginCredentialsManager) GetCredentialsFromConfig(arg0 *config.Config, arg1 config.MachineParams) func() (*auth.Credentials, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCredentialsFromConfig", arg0, arg1) + ret0, _ := ret[0].(func() (*auth.Credentials, error)) + return ret0 } -// GetOnPremSsoCredentialsFromConfigCalled returns true if GetOnPremSsoCredentialsFromConfig was called at least once. -func (m *LoginCredentialsManager) GetOnPremSsoCredentialsFromConfigCalled() bool { - m.lockGetOnPremSsoCredentialsFromConfig.Lock() - defer m.lockGetOnPremSsoCredentialsFromConfig.Unlock() +// GetCredentialsFromConfig indicates an expected call of GetCredentialsFromConfig. +func (mr *MockLoginCredentialsManagerMockRecorder) GetCredentialsFromConfig(arg0, arg1 any) *MockLoginCredentialsManagerGetCredentialsFromConfigCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCredentialsFromConfig", reflect.TypeOf((*MockLoginCredentialsManager)(nil).GetCredentialsFromConfig), arg0, arg1) + return &MockLoginCredentialsManagerGetCredentialsFromConfigCall{Call: call} +} - return len(m.calls.GetOnPremSsoCredentialsFromConfig) > 0 +// MockLoginCredentialsManagerGetCredentialsFromConfigCall wrap *gomock.Call +type MockLoginCredentialsManagerGetCredentialsFromConfigCall struct { + *gomock.Call } -// GetOnPremSsoCredentialsFromConfigCalls returns the calls made to GetOnPremSsoCredentialsFromConfig. -func (m *LoginCredentialsManager) GetOnPremSsoCredentialsFromConfigCalls() []struct { - Arg0 *github_com_confluentinc_cli_v4_pkg_config.Config - Arg1 bool -} { - m.lockGetOnPremSsoCredentialsFromConfig.Lock() - defer m.lockGetOnPremSsoCredentialsFromConfig.Unlock() +// Return rewrite *gomock.Call.Return +func (c *MockLoginCredentialsManagerGetCredentialsFromConfigCall) Return(arg0 func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetCredentialsFromConfigCall { + c.Call = c.Call.Return(arg0) + return c +} - return m.calls.GetOnPremSsoCredentialsFromConfig +// Do rewrite *gomock.Call.Do +func (c *MockLoginCredentialsManagerGetCredentialsFromConfigCall) Do(f func(*config.Config, config.MachineParams) func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetCredentialsFromConfigCall { + c.Call = c.Call.Do(f) + return c } -// GetOnPremCertOnlyCredentials mocks base method by wrapping the associated func. -func (m *LoginCredentialsManager) GetOnPremCertOnlyCredentials(certificateOnly bool) func() (*github_com_confluentinc_cli_v4_pkg_auth.Credentials, error) { - m.lockGetOnPremCertOnlyCredentials.Lock() - defer m.lockGetOnPremCertOnlyCredentials.Unlock() +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockLoginCredentialsManagerGetCredentialsFromConfigCall) DoAndReturn(f func(*config.Config, config.MachineParams) func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetCredentialsFromConfigCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - if m.GetOnPremCertOnlyCredentialsFunc == nil { - panic("mocker: LoginCredentialsManager.GetOnPremCertOnlyCredentialsFunc is nil but LoginCredentialsManager.GetOnPremCertOnlyCredentials was called.") - } +// GetCredentialsFromKeychain mocks base method. +func (m *MockLoginCredentialsManager) GetCredentialsFromKeychain(arg0 bool, arg1, arg2 string) func() (*auth.Credentials, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCredentialsFromKeychain", arg0, arg1, arg2) + ret0, _ := ret[0].(func() (*auth.Credentials, error)) + return ret0 +} - call := struct { - CertificateOnly bool - }{ - CertificateOnly: certificateOnly, - } +// GetCredentialsFromKeychain indicates an expected call of GetCredentialsFromKeychain. +func (mr *MockLoginCredentialsManagerMockRecorder) GetCredentialsFromKeychain(arg0, arg1, arg2 any) *MockLoginCredentialsManagerGetCredentialsFromKeychainCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCredentialsFromKeychain", reflect.TypeOf((*MockLoginCredentialsManager)(nil).GetCredentialsFromKeychain), arg0, arg1, arg2) + return &MockLoginCredentialsManagerGetCredentialsFromKeychainCall{Call: call} +} - m.calls.GetOnPremCertOnlyCredentials = append(m.calls.GetOnPremCertOnlyCredentials, call) +// MockLoginCredentialsManagerGetCredentialsFromKeychainCall wrap *gomock.Call +type MockLoginCredentialsManagerGetCredentialsFromKeychainCall struct { + *gomock.Call +} - return m.GetOnPremCertOnlyCredentialsFunc(certificateOnly) +// Return rewrite *gomock.Call.Return +func (c *MockLoginCredentialsManagerGetCredentialsFromKeychainCall) Return(arg0 func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetCredentialsFromKeychainCall { + c.Call = c.Call.Return(arg0) + return c } -// GetOnPremCertOnlyCredentialsCalled returns true if GetOnPremCertOnlyCredentials was called at least once. -func (m *LoginCredentialsManager) GetOnPremCertOnlyCredentialsCalled() bool { - m.lockGetOnPremCertOnlyCredentials.Lock() - defer m.lockGetOnPremCertOnlyCredentials.Unlock() +// Do rewrite *gomock.Call.Do +func (c *MockLoginCredentialsManagerGetCredentialsFromKeychainCall) Do(f func(bool, string, string) func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetCredentialsFromKeychainCall { + c.Call = c.Call.Do(f) + return c +} - return len(m.calls.GetOnPremCertOnlyCredentials) > 0 +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockLoginCredentialsManagerGetCredentialsFromKeychainCall) DoAndReturn(f func(bool, string, string) func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetCredentialsFromKeychainCall { + c.Call = c.Call.DoAndReturn(f) + return c } -// GetOnPremCertOnlyCredentialsCalls returns the calls made to GetOnPremCertOnlyCredentials. -func (m *LoginCredentialsManager) GetOnPremCertOnlyCredentialsCalls() []struct { - CertificateOnly bool -} { - m.lockGetOnPremCertOnlyCredentials.Lock() - defer m.lockGetOnPremCertOnlyCredentials.Unlock() +// GetOnPremCertOnlyCredentials mocks base method. +func (m *MockLoginCredentialsManager) GetOnPremCertOnlyCredentials(certificateOnly bool) func() (*auth.Credentials, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetOnPremCertOnlyCredentials", certificateOnly) + ret0, _ := ret[0].(func() (*auth.Credentials, error)) + return ret0 +} - return m.calls.GetOnPremCertOnlyCredentials +// GetOnPremCertOnlyCredentials indicates an expected call of GetOnPremCertOnlyCredentials. +func (mr *MockLoginCredentialsManagerMockRecorder) GetOnPremCertOnlyCredentials(certificateOnly any) *MockLoginCredentialsManagerGetOnPremCertOnlyCredentialsCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOnPremCertOnlyCredentials", reflect.TypeOf((*MockLoginCredentialsManager)(nil).GetOnPremCertOnlyCredentials), certificateOnly) + return &MockLoginCredentialsManagerGetOnPremCertOnlyCredentialsCall{Call: call} } -// GetCloudCredentialsFromPrompt mocks base method by wrapping the associated func. -func (m *LoginCredentialsManager) GetCloudCredentialsFromPrompt(arg0 string) func() (*github_com_confluentinc_cli_v4_pkg_auth.Credentials, error) { - m.lockGetCloudCredentialsFromPrompt.Lock() - defer m.lockGetCloudCredentialsFromPrompt.Unlock() +// MockLoginCredentialsManagerGetOnPremCertOnlyCredentialsCall wrap *gomock.Call +type MockLoginCredentialsManagerGetOnPremCertOnlyCredentialsCall struct { + *gomock.Call +} - if m.GetCloudCredentialsFromPromptFunc == nil { - panic("mocker: LoginCredentialsManager.GetCloudCredentialsFromPromptFunc is nil but LoginCredentialsManager.GetCloudCredentialsFromPrompt was called.") - } +// Return rewrite *gomock.Call.Return +func (c *MockLoginCredentialsManagerGetOnPremCertOnlyCredentialsCall) Return(arg0 func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetOnPremCertOnlyCredentialsCall { + c.Call = c.Call.Return(arg0) + return c +} - call := struct { - Arg0 string - }{ - Arg0: arg0, - } +// Do rewrite *gomock.Call.Do +func (c *MockLoginCredentialsManagerGetOnPremCertOnlyCredentialsCall) Do(f func(bool) func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetOnPremCertOnlyCredentialsCall { + c.Call = c.Call.Do(f) + return c +} - m.calls.GetCloudCredentialsFromPrompt = append(m.calls.GetCloudCredentialsFromPrompt, call) +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockLoginCredentialsManagerGetOnPremCertOnlyCredentialsCall) DoAndReturn(f func(bool) func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetOnPremCertOnlyCredentialsCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - return m.GetCloudCredentialsFromPromptFunc(arg0) +// GetOnPremCredentialsFromEnvVar mocks base method. +func (m *MockLoginCredentialsManager) GetOnPremCredentialsFromEnvVar() func() (*auth.Credentials, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetOnPremCredentialsFromEnvVar") + ret0, _ := ret[0].(func() (*auth.Credentials, error)) + return ret0 } -// GetCloudCredentialsFromPromptCalled returns true if GetCloudCredentialsFromPrompt was called at least once. -func (m *LoginCredentialsManager) GetCloudCredentialsFromPromptCalled() bool { - m.lockGetCloudCredentialsFromPrompt.Lock() - defer m.lockGetCloudCredentialsFromPrompt.Unlock() +// GetOnPremCredentialsFromEnvVar indicates an expected call of GetOnPremCredentialsFromEnvVar. +func (mr *MockLoginCredentialsManagerMockRecorder) GetOnPremCredentialsFromEnvVar() *MockLoginCredentialsManagerGetOnPremCredentialsFromEnvVarCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOnPremCredentialsFromEnvVar", reflect.TypeOf((*MockLoginCredentialsManager)(nil).GetOnPremCredentialsFromEnvVar)) + return &MockLoginCredentialsManagerGetOnPremCredentialsFromEnvVarCall{Call: call} +} - return len(m.calls.GetCloudCredentialsFromPrompt) > 0 +// MockLoginCredentialsManagerGetOnPremCredentialsFromEnvVarCall wrap *gomock.Call +type MockLoginCredentialsManagerGetOnPremCredentialsFromEnvVarCall struct { + *gomock.Call } -// GetCloudCredentialsFromPromptCalls returns the calls made to GetCloudCredentialsFromPrompt. -func (m *LoginCredentialsManager) GetCloudCredentialsFromPromptCalls() []struct { - Arg0 string -} { - m.lockGetCloudCredentialsFromPrompt.Lock() - defer m.lockGetCloudCredentialsFromPrompt.Unlock() +// Return rewrite *gomock.Call.Return +func (c *MockLoginCredentialsManagerGetOnPremCredentialsFromEnvVarCall) Return(arg0 func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetOnPremCredentialsFromEnvVarCall { + c.Call = c.Call.Return(arg0) + return c +} - return m.calls.GetCloudCredentialsFromPrompt +// Do rewrite *gomock.Call.Do +func (c *MockLoginCredentialsManagerGetOnPremCredentialsFromEnvVarCall) Do(f func() func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetOnPremCredentialsFromEnvVarCall { + c.Call = c.Call.Do(f) + return c } -// GetOnPremCredentialsFromPrompt mocks base method by wrapping the associated func. -func (m *LoginCredentialsManager) GetOnPremCredentialsFromPrompt() func() (*github_com_confluentinc_cli_v4_pkg_auth.Credentials, error) { - m.lockGetOnPremCredentialsFromPrompt.Lock() - defer m.lockGetOnPremCredentialsFromPrompt.Unlock() +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockLoginCredentialsManagerGetOnPremCredentialsFromEnvVarCall) DoAndReturn(f func() func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetOnPremCredentialsFromEnvVarCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - if m.GetOnPremCredentialsFromPromptFunc == nil { - panic("mocker: LoginCredentialsManager.GetOnPremCredentialsFromPromptFunc is nil but LoginCredentialsManager.GetOnPremCredentialsFromPrompt was called.") - } +// GetOnPremCredentialsFromPrompt mocks base method. +func (m *MockLoginCredentialsManager) GetOnPremCredentialsFromPrompt() func() (*auth.Credentials, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetOnPremCredentialsFromPrompt") + ret0, _ := ret[0].(func() (*auth.Credentials, error)) + return ret0 +} - call := struct { - }{} +// GetOnPremCredentialsFromPrompt indicates an expected call of GetOnPremCredentialsFromPrompt. +func (mr *MockLoginCredentialsManagerMockRecorder) GetOnPremCredentialsFromPrompt() *MockLoginCredentialsManagerGetOnPremCredentialsFromPromptCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOnPremCredentialsFromPrompt", reflect.TypeOf((*MockLoginCredentialsManager)(nil).GetOnPremCredentialsFromPrompt)) + return &MockLoginCredentialsManagerGetOnPremCredentialsFromPromptCall{Call: call} +} - m.calls.GetOnPremCredentialsFromPrompt = append(m.calls.GetOnPremCredentialsFromPrompt, call) +// MockLoginCredentialsManagerGetOnPremCredentialsFromPromptCall wrap *gomock.Call +type MockLoginCredentialsManagerGetOnPremCredentialsFromPromptCall struct { + *gomock.Call +} - return m.GetOnPremCredentialsFromPromptFunc() +// Return rewrite *gomock.Call.Return +func (c *MockLoginCredentialsManagerGetOnPremCredentialsFromPromptCall) Return(arg0 func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetOnPremCredentialsFromPromptCall { + c.Call = c.Call.Return(arg0) + return c } -// GetOnPremCredentialsFromPromptCalled returns true if GetOnPremCredentialsFromPrompt was called at least once. -func (m *LoginCredentialsManager) GetOnPremCredentialsFromPromptCalled() bool { - m.lockGetOnPremCredentialsFromPrompt.Lock() - defer m.lockGetOnPremCredentialsFromPrompt.Unlock() +// Do rewrite *gomock.Call.Do +func (c *MockLoginCredentialsManagerGetOnPremCredentialsFromPromptCall) Do(f func() func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetOnPremCredentialsFromPromptCall { + c.Call = c.Call.Do(f) + return c +} - return len(m.calls.GetOnPremCredentialsFromPrompt) > 0 +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockLoginCredentialsManagerGetOnPremCredentialsFromPromptCall) DoAndReturn(f func() func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetOnPremCredentialsFromPromptCall { + c.Call = c.Call.DoAndReturn(f) + return c } -// GetOnPremCredentialsFromPromptCalls returns the calls made to GetOnPremCredentialsFromPrompt. -func (m *LoginCredentialsManager) GetOnPremCredentialsFromPromptCalls() []struct { -} { - m.lockGetOnPremCredentialsFromPrompt.Lock() - defer m.lockGetOnPremCredentialsFromPrompt.Unlock() +// GetOnPremPrerunCredentialsFromEnvVar mocks base method. +func (m *MockLoginCredentialsManager) GetOnPremPrerunCredentialsFromEnvVar() func() (*auth.Credentials, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetOnPremPrerunCredentialsFromEnvVar") + ret0, _ := ret[0].(func() (*auth.Credentials, error)) + return ret0 +} - return m.calls.GetOnPremCredentialsFromPrompt +// GetOnPremPrerunCredentialsFromEnvVar indicates an expected call of GetOnPremPrerunCredentialsFromEnvVar. +func (mr *MockLoginCredentialsManagerMockRecorder) GetOnPremPrerunCredentialsFromEnvVar() *MockLoginCredentialsManagerGetOnPremPrerunCredentialsFromEnvVarCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOnPremPrerunCredentialsFromEnvVar", reflect.TypeOf((*MockLoginCredentialsManager)(nil).GetOnPremPrerunCredentialsFromEnvVar)) + return &MockLoginCredentialsManagerGetOnPremPrerunCredentialsFromEnvVarCall{Call: call} } -// GetPrerunCredentialsFromConfig mocks base method by wrapping the associated func. -func (m *LoginCredentialsManager) GetPrerunCredentialsFromConfig(arg0 *github_com_confluentinc_cli_v4_pkg_config.Config) func() (*github_com_confluentinc_cli_v4_pkg_auth.Credentials, error) { - m.lockGetPrerunCredentialsFromConfig.Lock() - defer m.lockGetPrerunCredentialsFromConfig.Unlock() +// MockLoginCredentialsManagerGetOnPremPrerunCredentialsFromEnvVarCall wrap *gomock.Call +type MockLoginCredentialsManagerGetOnPremPrerunCredentialsFromEnvVarCall struct { + *gomock.Call +} - if m.GetPrerunCredentialsFromConfigFunc == nil { - panic("mocker: LoginCredentialsManager.GetPrerunCredentialsFromConfigFunc is nil but LoginCredentialsManager.GetPrerunCredentialsFromConfig was called.") - } +// Return rewrite *gomock.Call.Return +func (c *MockLoginCredentialsManagerGetOnPremPrerunCredentialsFromEnvVarCall) Return(arg0 func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetOnPremPrerunCredentialsFromEnvVarCall { + c.Call = c.Call.Return(arg0) + return c +} - call := struct { - Arg0 *github_com_confluentinc_cli_v4_pkg_config.Config - }{ - Arg0: arg0, - } +// Do rewrite *gomock.Call.Do +func (c *MockLoginCredentialsManagerGetOnPremPrerunCredentialsFromEnvVarCall) Do(f func() func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetOnPremPrerunCredentialsFromEnvVarCall { + c.Call = c.Call.Do(f) + return c +} - m.calls.GetPrerunCredentialsFromConfig = append(m.calls.GetPrerunCredentialsFromConfig, call) +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockLoginCredentialsManagerGetOnPremPrerunCredentialsFromEnvVarCall) DoAndReturn(f func() func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetOnPremPrerunCredentialsFromEnvVarCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - return m.GetPrerunCredentialsFromConfigFunc(arg0) +// GetOnPremSsoCredentials mocks base method. +func (m *MockLoginCredentialsManager) GetOnPremSsoCredentials(url, caCertPath, clientCertPath, clientKeyPath string, unsafeTrace bool) func() (*auth.Credentials, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetOnPremSsoCredentials", url, caCertPath, clientCertPath, clientKeyPath, unsafeTrace) + ret0, _ := ret[0].(func() (*auth.Credentials, error)) + return ret0 } -// GetPrerunCredentialsFromConfigCalled returns true if GetPrerunCredentialsFromConfig was called at least once. -func (m *LoginCredentialsManager) GetPrerunCredentialsFromConfigCalled() bool { - m.lockGetPrerunCredentialsFromConfig.Lock() - defer m.lockGetPrerunCredentialsFromConfig.Unlock() +// GetOnPremSsoCredentials indicates an expected call of GetOnPremSsoCredentials. +func (mr *MockLoginCredentialsManagerMockRecorder) GetOnPremSsoCredentials(url, caCertPath, clientCertPath, clientKeyPath, unsafeTrace any) *MockLoginCredentialsManagerGetOnPremSsoCredentialsCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOnPremSsoCredentials", reflect.TypeOf((*MockLoginCredentialsManager)(nil).GetOnPremSsoCredentials), url, caCertPath, clientCertPath, clientKeyPath, unsafeTrace) + return &MockLoginCredentialsManagerGetOnPremSsoCredentialsCall{Call: call} +} - return len(m.calls.GetPrerunCredentialsFromConfig) > 0 +// MockLoginCredentialsManagerGetOnPremSsoCredentialsCall wrap *gomock.Call +type MockLoginCredentialsManagerGetOnPremSsoCredentialsCall struct { + *gomock.Call } -// GetPrerunCredentialsFromConfigCalls returns the calls made to GetPrerunCredentialsFromConfig. -func (m *LoginCredentialsManager) GetPrerunCredentialsFromConfigCalls() []struct { - Arg0 *github_com_confluentinc_cli_v4_pkg_config.Config -} { - m.lockGetPrerunCredentialsFromConfig.Lock() - defer m.lockGetPrerunCredentialsFromConfig.Unlock() +// Return rewrite *gomock.Call.Return +func (c *MockLoginCredentialsManagerGetOnPremSsoCredentialsCall) Return(arg0 func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetOnPremSsoCredentialsCall { + c.Call = c.Call.Return(arg0) + return c +} - return m.calls.GetPrerunCredentialsFromConfig +// Do rewrite *gomock.Call.Do +func (c *MockLoginCredentialsManagerGetOnPremSsoCredentialsCall) Do(f func(string, string, string, string, bool) func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetOnPremSsoCredentialsCall { + c.Call = c.Call.Do(f) + return c } -// GetOnPremPrerunCredentialsFromEnvVar mocks base method by wrapping the associated func. -func (m *LoginCredentialsManager) GetOnPremPrerunCredentialsFromEnvVar() func() (*github_com_confluentinc_cli_v4_pkg_auth.Credentials, error) { - m.lockGetOnPremPrerunCredentialsFromEnvVar.Lock() - defer m.lockGetOnPremPrerunCredentialsFromEnvVar.Unlock() +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockLoginCredentialsManagerGetOnPremSsoCredentialsCall) DoAndReturn(f func(string, string, string, string, bool) func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetOnPremSsoCredentialsCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - if m.GetOnPremPrerunCredentialsFromEnvVarFunc == nil { - panic("mocker: LoginCredentialsManager.GetOnPremPrerunCredentialsFromEnvVarFunc is nil but LoginCredentialsManager.GetOnPremPrerunCredentialsFromEnvVar was called.") - } +// GetOnPremSsoCredentialsFromConfig mocks base method. +func (m *MockLoginCredentialsManager) GetOnPremSsoCredentialsFromConfig(arg0 *config.Config, arg1 bool) func() (*auth.Credentials, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetOnPremSsoCredentialsFromConfig", arg0, arg1) + ret0, _ := ret[0].(func() (*auth.Credentials, error)) + return ret0 +} - call := struct { - }{} +// GetOnPremSsoCredentialsFromConfig indicates an expected call of GetOnPremSsoCredentialsFromConfig. +func (mr *MockLoginCredentialsManagerMockRecorder) GetOnPremSsoCredentialsFromConfig(arg0, arg1 any) *MockLoginCredentialsManagerGetOnPremSsoCredentialsFromConfigCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOnPremSsoCredentialsFromConfig", reflect.TypeOf((*MockLoginCredentialsManager)(nil).GetOnPremSsoCredentialsFromConfig), arg0, arg1) + return &MockLoginCredentialsManagerGetOnPremSsoCredentialsFromConfigCall{Call: call} +} - m.calls.GetOnPremPrerunCredentialsFromEnvVar = append(m.calls.GetOnPremPrerunCredentialsFromEnvVar, call) +// MockLoginCredentialsManagerGetOnPremSsoCredentialsFromConfigCall wrap *gomock.Call +type MockLoginCredentialsManagerGetOnPremSsoCredentialsFromConfigCall struct { + *gomock.Call +} - return m.GetOnPremPrerunCredentialsFromEnvVarFunc() +// Return rewrite *gomock.Call.Return +func (c *MockLoginCredentialsManagerGetOnPremSsoCredentialsFromConfigCall) Return(arg0 func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetOnPremSsoCredentialsFromConfigCall { + c.Call = c.Call.Return(arg0) + return c } -// GetOnPremPrerunCredentialsFromEnvVarCalled returns true if GetOnPremPrerunCredentialsFromEnvVar was called at least once. -func (m *LoginCredentialsManager) GetOnPremPrerunCredentialsFromEnvVarCalled() bool { - m.lockGetOnPremPrerunCredentialsFromEnvVar.Lock() - defer m.lockGetOnPremPrerunCredentialsFromEnvVar.Unlock() +// Do rewrite *gomock.Call.Do +func (c *MockLoginCredentialsManagerGetOnPremSsoCredentialsFromConfigCall) Do(f func(*config.Config, bool) func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetOnPremSsoCredentialsFromConfigCall { + c.Call = c.Call.Do(f) + return c +} - return len(m.calls.GetOnPremPrerunCredentialsFromEnvVar) > 0 +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockLoginCredentialsManagerGetOnPremSsoCredentialsFromConfigCall) DoAndReturn(f func(*config.Config, bool) func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetOnPremSsoCredentialsFromConfigCall { + c.Call = c.Call.DoAndReturn(f) + return c } -// GetOnPremPrerunCredentialsFromEnvVarCalls returns the calls made to GetOnPremPrerunCredentialsFromEnvVar. -func (m *LoginCredentialsManager) GetOnPremPrerunCredentialsFromEnvVarCalls() []struct { -} { - m.lockGetOnPremPrerunCredentialsFromEnvVar.Lock() - defer m.lockGetOnPremPrerunCredentialsFromEnvVar.Unlock() +// GetPrerunCredentialsFromConfig mocks base method. +func (m *MockLoginCredentialsManager) GetPrerunCredentialsFromConfig(arg0 *config.Config) func() (*auth.Credentials, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetPrerunCredentialsFromConfig", arg0) + ret0, _ := ret[0].(func() (*auth.Credentials, error)) + return ret0 +} - return m.calls.GetOnPremPrerunCredentialsFromEnvVar +// GetPrerunCredentialsFromConfig indicates an expected call of GetPrerunCredentialsFromConfig. +func (mr *MockLoginCredentialsManagerMockRecorder) GetPrerunCredentialsFromConfig(arg0 any) *MockLoginCredentialsManagerGetPrerunCredentialsFromConfigCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPrerunCredentialsFromConfig", reflect.TypeOf((*MockLoginCredentialsManager)(nil).GetPrerunCredentialsFromConfig), arg0) + return &MockLoginCredentialsManagerGetPrerunCredentialsFromConfigCall{Call: call} } -// SetCloudClient mocks base method by wrapping the associated func. -func (m *LoginCredentialsManager) SetCloudClient(arg0 *github_com_confluentinc_ccloud_sdk_go_v1_public.Client) { - m.lockSetCloudClient.Lock() - defer m.lockSetCloudClient.Unlock() +// MockLoginCredentialsManagerGetPrerunCredentialsFromConfigCall wrap *gomock.Call +type MockLoginCredentialsManagerGetPrerunCredentialsFromConfigCall struct { + *gomock.Call +} - if m.SetCloudClientFunc == nil { - panic("mocker: LoginCredentialsManager.SetCloudClientFunc is nil but LoginCredentialsManager.SetCloudClient was called.") - } +// Return rewrite *gomock.Call.Return +func (c *MockLoginCredentialsManagerGetPrerunCredentialsFromConfigCall) Return(arg0 func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetPrerunCredentialsFromConfigCall { + c.Call = c.Call.Return(arg0) + return c +} - call := struct { - Arg0 *github_com_confluentinc_ccloud_sdk_go_v1_public.Client - }{ - Arg0: arg0, - } +// Do rewrite *gomock.Call.Do +func (c *MockLoginCredentialsManagerGetPrerunCredentialsFromConfigCall) Do(f func(*config.Config) func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetPrerunCredentialsFromConfigCall { + c.Call = c.Call.Do(f) + return c +} - m.calls.SetCloudClient = append(m.calls.SetCloudClient, call) +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockLoginCredentialsManagerGetPrerunCredentialsFromConfigCall) DoAndReturn(f func(*config.Config) func() (*auth.Credentials, error)) *MockLoginCredentialsManagerGetPrerunCredentialsFromConfigCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - m.SetCloudClientFunc(arg0) +// SetCloudClient mocks base method. +func (m *MockLoginCredentialsManager) SetCloudClient(arg0 *ccloud.Client) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetCloudClient", arg0) } -// SetCloudClientCalled returns true if SetCloudClient was called at least once. -func (m *LoginCredentialsManager) SetCloudClientCalled() bool { - m.lockSetCloudClient.Lock() - defer m.lockSetCloudClient.Unlock() +// SetCloudClient indicates an expected call of SetCloudClient. +func (mr *MockLoginCredentialsManagerMockRecorder) SetCloudClient(arg0 any) *MockLoginCredentialsManagerSetCloudClientCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetCloudClient", reflect.TypeOf((*MockLoginCredentialsManager)(nil).SetCloudClient), arg0) + return &MockLoginCredentialsManagerSetCloudClientCall{Call: call} +} - return len(m.calls.SetCloudClient) > 0 +// MockLoginCredentialsManagerSetCloudClientCall wrap *gomock.Call +type MockLoginCredentialsManagerSetCloudClientCall struct { + *gomock.Call } -// SetCloudClientCalls returns the calls made to SetCloudClient. -func (m *LoginCredentialsManager) SetCloudClientCalls() []struct { - Arg0 *github_com_confluentinc_ccloud_sdk_go_v1_public.Client -} { - m.lockSetCloudClient.Lock() - defer m.lockSetCloudClient.Unlock() +// Return rewrite *gomock.Call.Return +func (c *MockLoginCredentialsManagerSetCloudClientCall) Return() *MockLoginCredentialsManagerSetCloudClientCall { + c.Call = c.Call.Return() + return c +} - return m.calls.SetCloudClient +// Do rewrite *gomock.Call.Do +func (c *MockLoginCredentialsManagerSetCloudClientCall) Do(f func(*ccloud.Client)) *MockLoginCredentialsManagerSetCloudClientCall { + c.Call = c.Call.Do(f) + return c } -// Reset resets the calls made to the mocked methods. -func (m *LoginCredentialsManager) Reset() { - m.lockGetCloudCredentialsFromEnvVar.Lock() - m.calls.GetCloudCredentialsFromEnvVar = nil - m.lockGetCloudCredentialsFromEnvVar.Unlock() - m.lockGetOnPremCredentialsFromEnvVar.Lock() - m.calls.GetOnPremCredentialsFromEnvVar = nil - m.lockGetOnPremCredentialsFromEnvVar.Unlock() - m.lockGetCredentialsFromConfig.Lock() - m.calls.GetCredentialsFromConfig = nil - m.lockGetCredentialsFromConfig.Unlock() - m.lockGetCredentialsFromKeychain.Lock() - m.calls.GetCredentialsFromKeychain = nil - m.lockGetCredentialsFromKeychain.Unlock() - m.lockGetOnPremSsoCredentials.Lock() - m.calls.GetOnPremSsoCredentials = nil - m.lockGetOnPremSsoCredentials.Unlock() - m.lockGetOnPremSsoCredentialsFromConfig.Lock() - m.calls.GetOnPremSsoCredentialsFromConfig = nil - m.lockGetOnPremSsoCredentialsFromConfig.Unlock() - m.lockGetOnPremCertOnlyCredentials.Lock() - m.calls.GetOnPremCertOnlyCredentials = nil - m.lockGetOnPremCertOnlyCredentials.Unlock() - m.lockGetCloudCredentialsFromPrompt.Lock() - m.calls.GetCloudCredentialsFromPrompt = nil - m.lockGetCloudCredentialsFromPrompt.Unlock() - m.lockGetOnPremCredentialsFromPrompt.Lock() - m.calls.GetOnPremCredentialsFromPrompt = nil - m.lockGetOnPremCredentialsFromPrompt.Unlock() - m.lockGetPrerunCredentialsFromConfig.Lock() - m.calls.GetPrerunCredentialsFromConfig = nil - m.lockGetPrerunCredentialsFromConfig.Unlock() - m.lockGetOnPremPrerunCredentialsFromEnvVar.Lock() - m.calls.GetOnPremPrerunCredentialsFromEnvVar = nil - m.lockGetOnPremPrerunCredentialsFromEnvVar.Unlock() - m.lockSetCloudClient.Lock() - m.calls.SetCloudClient = nil - m.lockSetCloudClient.Unlock() +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockLoginCredentialsManagerSetCloudClientCall) DoAndReturn(f func(*ccloud.Client)) *MockLoginCredentialsManagerSetCloudClientCall { + c.Call = c.Call.DoAndReturn(f) + return c } diff --git a/mock/login_organization_manager.go b/mock/login_organization_manager.go index b6fac95f61..2f04300777 100644 --- a/mock/login_organization_manager.go +++ b/mock/login_organization_manager.go @@ -1,158 +1,156 @@ -// Code generated by mocker. DO NOT EDIT. -// github.com/travisjeffery/mocker -// Source: login_organization_manager.go - +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/confluentinc/cli/v4/pkg/auth (interfaces: LoginOrganizationManager) +// +// Generated by this command: +// +// mockgen -typed -destination=../../mock/login_organization_manager.go -package=mock github.com/confluentinc/cli/v4/pkg/auth LoginOrganizationManager +// + +// Package mock is a generated GoMock package. package mock import ( - sync "sync" + reflect "reflect" - github_com_confluentinc_cli_internal_pkg_config "github.com/confluentinc/cli/v4/pkg/config" - github_com_spf13_cobra "github.com/spf13/cobra" + config "github.com/confluentinc/cli/v4/pkg/config" + cobra "github.com/spf13/cobra" + gomock "go.uber.org/mock/gomock" ) -// LoginOrganizationManager is a mock of LoginOrganizationManager interface -type LoginOrganizationManager struct { - lockGetLoginOrganizationFromFlag sync.Mutex - GetLoginOrganizationFromFlagFunc func(arg0 *github_com_spf13_cobra.Command) func() string - - lockGetLoginOrganizationFromEnvironmentVariable sync.Mutex - GetLoginOrganizationFromEnvironmentVariableFunc func() func() string - - lockGetLoginOrganizationFromConfigurationFile sync.Mutex - GetLoginOrganizationFromConfigurationFileFunc func(cfg *github_com_confluentinc_cli_internal_pkg_config.Config) func() string - - calls struct { - GetLoginOrganizationFromFlag []struct { - Arg0 *github_com_spf13_cobra.Command - } - GetLoginOrganizationFromEnvironmentVariable []struct { - } - GetLoginOrganizationFromConfigurationFile []struct { - Cfg *github_com_confluentinc_cli_internal_pkg_config.Config - } - } +// MockLoginOrganizationManager is a mock of LoginOrganizationManager interface. +type MockLoginOrganizationManager struct { + ctrl *gomock.Controller + recorder *MockLoginOrganizationManagerMockRecorder + isgomock struct{} } -// GetLoginOrganizationFromFlag mocks base method by wrapping the associated func. -func (m *LoginOrganizationManager) GetLoginOrganizationFromFlag(arg0 *github_com_spf13_cobra.Command) func() string { - m.lockGetLoginOrganizationFromFlag.Lock() - defer m.lockGetLoginOrganizationFromFlag.Unlock() - - if m.GetLoginOrganizationFromFlagFunc == nil { - panic("mocker: LoginOrganizationManager.GetLoginOrganizationFromFlagFunc is nil but LoginOrganizationManager.GetLoginOrganizationFromFlag was called.") - } - - call := struct { - Arg0 *github_com_spf13_cobra.Command - }{ - Arg0: arg0, - } - - m.calls.GetLoginOrganizationFromFlag = append(m.calls.GetLoginOrganizationFromFlag, call) - - return m.GetLoginOrganizationFromFlagFunc(arg0) +// MockLoginOrganizationManagerMockRecorder is the mock recorder for MockLoginOrganizationManager. +type MockLoginOrganizationManagerMockRecorder struct { + mock *MockLoginOrganizationManager } -// GetLoginOrganizationFromFlagCalled returns true if GetLoginOrganizationFromFlag was called at least once. -func (m *LoginOrganizationManager) GetLoginOrganizationFromFlagCalled() bool { - m.lockGetLoginOrganizationFromFlag.Lock() - defer m.lockGetLoginOrganizationFromFlag.Unlock() - - return len(m.calls.GetLoginOrganizationFromFlag) > 0 +// NewMockLoginOrganizationManager creates a new mock instance. +func NewMockLoginOrganizationManager(ctrl *gomock.Controller) *MockLoginOrganizationManager { + mock := &MockLoginOrganizationManager{ctrl: ctrl} + mock.recorder = &MockLoginOrganizationManagerMockRecorder{mock} + return mock } -// GetLoginOrganizationFromFlagCalls returns the calls made to GetLoginOrganizationFromFlag. -func (m *LoginOrganizationManager) GetLoginOrganizationFromFlagCalls() []struct { - Arg0 *github_com_spf13_cobra.Command -} { - m.lockGetLoginOrganizationFromFlag.Lock() - defer m.lockGetLoginOrganizationFromFlag.Unlock() - - return m.calls.GetLoginOrganizationFromFlag +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockLoginOrganizationManager) EXPECT() *MockLoginOrganizationManagerMockRecorder { + return m.recorder } -// GetLoginOrganizationFromEnvironmentVariable mocks base method by wrapping the associated func. -func (m *LoginOrganizationManager) GetLoginOrganizationFromEnvironmentVariable() func() string { - m.lockGetLoginOrganizationFromEnvironmentVariable.Lock() - defer m.lockGetLoginOrganizationFromEnvironmentVariable.Unlock() - - if m.GetLoginOrganizationFromEnvironmentVariableFunc == nil { - panic("mocker: LoginOrganizationManager.GetLoginOrganizationFromEnvironmentVariableFunc is nil but LoginOrganizationManager.GetLoginOrganizationFromEnvironmentVariable was called.") - } +// GetLoginOrganizationFromConfigurationFile mocks base method. +func (m *MockLoginOrganizationManager) GetLoginOrganizationFromConfigurationFile(cfg *config.Config) func() string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetLoginOrganizationFromConfigurationFile", cfg) + ret0, _ := ret[0].(func() string) + return ret0 +} - call := struct { - }{} +// GetLoginOrganizationFromConfigurationFile indicates an expected call of GetLoginOrganizationFromConfigurationFile. +func (mr *MockLoginOrganizationManagerMockRecorder) GetLoginOrganizationFromConfigurationFile(cfg any) *MockLoginOrganizationManagerGetLoginOrganizationFromConfigurationFileCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLoginOrganizationFromConfigurationFile", reflect.TypeOf((*MockLoginOrganizationManager)(nil).GetLoginOrganizationFromConfigurationFile), cfg) + return &MockLoginOrganizationManagerGetLoginOrganizationFromConfigurationFileCall{Call: call} +} - m.calls.GetLoginOrganizationFromEnvironmentVariable = append(m.calls.GetLoginOrganizationFromEnvironmentVariable, call) +// MockLoginOrganizationManagerGetLoginOrganizationFromConfigurationFileCall wrap *gomock.Call +type MockLoginOrganizationManagerGetLoginOrganizationFromConfigurationFileCall struct { + *gomock.Call +} - return m.GetLoginOrganizationFromEnvironmentVariableFunc() +// Return rewrite *gomock.Call.Return +func (c *MockLoginOrganizationManagerGetLoginOrganizationFromConfigurationFileCall) Return(arg0 func() string) *MockLoginOrganizationManagerGetLoginOrganizationFromConfigurationFileCall { + c.Call = c.Call.Return(arg0) + return c } -// GetLoginOrganizationFromEnvironmentVariableCalled returns true if GetLoginOrganizationFromEnvironmentVariable was called at least once. -func (m *LoginOrganizationManager) GetLoginOrganizationFromEnvironmentVariableCalled() bool { - m.lockGetLoginOrganizationFromEnvironmentVariable.Lock() - defer m.lockGetLoginOrganizationFromEnvironmentVariable.Unlock() +// Do rewrite *gomock.Call.Do +func (c *MockLoginOrganizationManagerGetLoginOrganizationFromConfigurationFileCall) Do(f func(*config.Config) func() string) *MockLoginOrganizationManagerGetLoginOrganizationFromConfigurationFileCall { + c.Call = c.Call.Do(f) + return c +} - return len(m.calls.GetLoginOrganizationFromEnvironmentVariable) > 0 +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockLoginOrganizationManagerGetLoginOrganizationFromConfigurationFileCall) DoAndReturn(f func(*config.Config) func() string) *MockLoginOrganizationManagerGetLoginOrganizationFromConfigurationFileCall { + c.Call = c.Call.DoAndReturn(f) + return c } -// GetLoginOrganizationFromEnvironmentVariableCalls returns the calls made to GetLoginOrganizationFromEnvironmentVariable. -func (m *LoginOrganizationManager) GetLoginOrganizationFromEnvironmentVariableCalls() []struct { -} { - m.lockGetLoginOrganizationFromEnvironmentVariable.Lock() - defer m.lockGetLoginOrganizationFromEnvironmentVariable.Unlock() +// GetLoginOrganizationFromEnvironmentVariable mocks base method. +func (m *MockLoginOrganizationManager) GetLoginOrganizationFromEnvironmentVariable() func() string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetLoginOrganizationFromEnvironmentVariable") + ret0, _ := ret[0].(func() string) + return ret0 +} - return m.calls.GetLoginOrganizationFromEnvironmentVariable +// GetLoginOrganizationFromEnvironmentVariable indicates an expected call of GetLoginOrganizationFromEnvironmentVariable. +func (mr *MockLoginOrganizationManagerMockRecorder) GetLoginOrganizationFromEnvironmentVariable() *MockLoginOrganizationManagerGetLoginOrganizationFromEnvironmentVariableCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLoginOrganizationFromEnvironmentVariable", reflect.TypeOf((*MockLoginOrganizationManager)(nil).GetLoginOrganizationFromEnvironmentVariable)) + return &MockLoginOrganizationManagerGetLoginOrganizationFromEnvironmentVariableCall{Call: call} } -// GetLoginOrganizationFromConfigurationFile mocks base method by wrapping the associated func. -func (m *LoginOrganizationManager) GetLoginOrganizationFromConfigurationFile(cfg *github_com_confluentinc_cli_internal_pkg_config.Config) func() string { - m.lockGetLoginOrganizationFromConfigurationFile.Lock() - defer m.lockGetLoginOrganizationFromConfigurationFile.Unlock() +// MockLoginOrganizationManagerGetLoginOrganizationFromEnvironmentVariableCall wrap *gomock.Call +type MockLoginOrganizationManagerGetLoginOrganizationFromEnvironmentVariableCall struct { + *gomock.Call +} - if m.GetLoginOrganizationFromConfigurationFileFunc == nil { - panic("mocker: LoginOrganizationManager.GetLoginOrganizationFromConfigurationFileFunc is nil but LoginOrganizationManager.GetLoginOrganizationFromConfigurationFile was called.") - } +// Return rewrite *gomock.Call.Return +func (c *MockLoginOrganizationManagerGetLoginOrganizationFromEnvironmentVariableCall) Return(arg0 func() string) *MockLoginOrganizationManagerGetLoginOrganizationFromEnvironmentVariableCall { + c.Call = c.Call.Return(arg0) + return c +} - call := struct { - Cfg *github_com_confluentinc_cli_internal_pkg_config.Config - }{ - Cfg: cfg, - } +// Do rewrite *gomock.Call.Do +func (c *MockLoginOrganizationManagerGetLoginOrganizationFromEnvironmentVariableCall) Do(f func() func() string) *MockLoginOrganizationManagerGetLoginOrganizationFromEnvironmentVariableCall { + c.Call = c.Call.Do(f) + return c +} - m.calls.GetLoginOrganizationFromConfigurationFile = append(m.calls.GetLoginOrganizationFromConfigurationFile, call) +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockLoginOrganizationManagerGetLoginOrganizationFromEnvironmentVariableCall) DoAndReturn(f func() func() string) *MockLoginOrganizationManagerGetLoginOrganizationFromEnvironmentVariableCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - return m.GetLoginOrganizationFromConfigurationFileFunc(cfg) +// GetLoginOrganizationFromFlag mocks base method. +func (m *MockLoginOrganizationManager) GetLoginOrganizationFromFlag(arg0 *cobra.Command) func() string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetLoginOrganizationFromFlag", arg0) + ret0, _ := ret[0].(func() string) + return ret0 } -// GetLoginOrganizationFromConfigurationFileCalled returns true if GetLoginOrganizationFromConfigurationFile was called at least once. -func (m *LoginOrganizationManager) GetLoginOrganizationFromConfigurationFileCalled() bool { - m.lockGetLoginOrganizationFromConfigurationFile.Lock() - defer m.lockGetLoginOrganizationFromConfigurationFile.Unlock() +// GetLoginOrganizationFromFlag indicates an expected call of GetLoginOrganizationFromFlag. +func (mr *MockLoginOrganizationManagerMockRecorder) GetLoginOrganizationFromFlag(arg0 any) *MockLoginOrganizationManagerGetLoginOrganizationFromFlagCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLoginOrganizationFromFlag", reflect.TypeOf((*MockLoginOrganizationManager)(nil).GetLoginOrganizationFromFlag), arg0) + return &MockLoginOrganizationManagerGetLoginOrganizationFromFlagCall{Call: call} +} - return len(m.calls.GetLoginOrganizationFromConfigurationFile) > 0 +// MockLoginOrganizationManagerGetLoginOrganizationFromFlagCall wrap *gomock.Call +type MockLoginOrganizationManagerGetLoginOrganizationFromFlagCall struct { + *gomock.Call } -// GetLoginOrganizationFromConfigurationFileCalls returns the calls made to GetLoginOrganizationFromConfigurationFile. -func (m *LoginOrganizationManager) GetLoginOrganizationFromConfigurationFileCalls() []struct { - Cfg *github_com_confluentinc_cli_internal_pkg_config.Config -} { - m.lockGetLoginOrganizationFromConfigurationFile.Lock() - defer m.lockGetLoginOrganizationFromConfigurationFile.Unlock() +// Return rewrite *gomock.Call.Return +func (c *MockLoginOrganizationManagerGetLoginOrganizationFromFlagCall) Return(arg0 func() string) *MockLoginOrganizationManagerGetLoginOrganizationFromFlagCall { + c.Call = c.Call.Return(arg0) + return c +} - return m.calls.GetLoginOrganizationFromConfigurationFile +// Do rewrite *gomock.Call.Do +func (c *MockLoginOrganizationManagerGetLoginOrganizationFromFlagCall) Do(f func(*cobra.Command) func() string) *MockLoginOrganizationManagerGetLoginOrganizationFromFlagCall { + c.Call = c.Call.Do(f) + return c } -// Reset resets the calls made to the mocked methods. -func (m *LoginOrganizationManager) Reset() { - m.lockGetLoginOrganizationFromFlag.Lock() - m.calls.GetLoginOrganizationFromFlag = nil - m.lockGetLoginOrganizationFromFlag.Unlock() - m.lockGetLoginOrganizationFromEnvironmentVariable.Lock() - m.calls.GetLoginOrganizationFromEnvironmentVariable = nil - m.lockGetLoginOrganizationFromEnvironmentVariable.Unlock() - m.lockGetLoginOrganizationFromConfigurationFile.Lock() - m.calls.GetLoginOrganizationFromConfigurationFile = nil - m.lockGetLoginOrganizationFromConfigurationFile.Unlock() +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockLoginOrganizationManagerGetLoginOrganizationFromFlagCall) DoAndReturn(f func(*cobra.Command) func() string) *MockLoginOrganizationManagerGetLoginOrganizationFromFlagCall { + c.Call = c.Call.DoAndReturn(f) + return c } diff --git a/pkg/auth/auth_token_handler.go b/pkg/auth/auth_token_handler.go index c09845611a..d3cbe5bf77 100644 --- a/pkg/auth/auth_token_handler.go +++ b/pkg/auth/auth_token_handler.go @@ -1,4 +1,4 @@ -//go:generate go run github.com/travisjeffery/mocker/cmd/mocker --dst ../../mock/auth_token_handler.go --pkg mock --selfpkg github.com/confluentinc/cli/v4 auth_token_handler.go AuthTokenHandler +//go:generate go run go.uber.org/mock/mockgen -typed -destination=../../mock/auth_token_handler.go -package=mock github.com/confluentinc/cli/v4/pkg/auth AuthTokenHandler package auth import ( diff --git a/pkg/auth/ccloud_client_factory.go b/pkg/auth/ccloud_client_factory.go index 27863ba97b..b7c083957b 100644 --- a/pkg/auth/ccloud_client_factory.go +++ b/pkg/auth/ccloud_client_factory.go @@ -1,4 +1,4 @@ -//go:generate go run github.com/travisjeffery/mocker/cmd/mocker --dst ../../mock/ccloud_client_factory.go --pkg mock --selfpkg github.com/confluentinc/cli/v4 ccloud_client_factory.go CCloudClientFactory +//go:generate go run go.uber.org/mock/mockgen -typed -destination=../../mock/ccloud_client_factory.go -package=mock github.com/confluentinc/cli/v4/pkg/auth CCloudClientFactory package auth import ( diff --git a/pkg/auth/login_credentials_manager.go b/pkg/auth/login_credentials_manager.go index 7280bfd0be..f578dcfade 100644 --- a/pkg/auth/login_credentials_manager.go +++ b/pkg/auth/login_credentials_manager.go @@ -1,4 +1,4 @@ -//go:generate mocker --dst ../../mock/login_credentials_manager.go --pkg mock --selfpkg github.com/confluentinc/cli/v4 login_credentials_manager.go LoginCredentialsManager --prefix "" +//go:generate go run go.uber.org/mock/mockgen -typed -destination=../../mock/login_credentials_manager.go -package=mock github.com/confluentinc/cli/v4/pkg/auth LoginCredentialsManager package auth import ( diff --git a/pkg/auth/login_credentials_manager_test.go b/pkg/auth/login_credentials_manager_test.go index e287fb7343..6d92641c30 100644 --- a/pkg/auth/login_credentials_manager_test.go +++ b/pkg/auth/login_credentials_manager_test.go @@ -8,6 +8,7 @@ import ( "github.com/spf13/cobra" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + "go.uber.org/mock/gomock" ccloudv1 "github.com/confluentinc/ccloud-sdk-go-v1-public" ccloudv1mock "github.com/confluentinc/ccloud-sdk-go-v1-public/mock" @@ -58,7 +59,7 @@ type LoginCredentialsManagerTestSuite struct { require *require.Assertions ccloudClient *ccloudv1.Client - prompt *mock.Prompt + prompt *mock.MockPrompt loginCredentialsManager LoginCredentialsManager } @@ -81,20 +82,16 @@ func (suite *LoginCredentialsManagerTestSuite) SetupSuite() { }, }, } - suite.prompt = &mock.Prompt{ - ReadLineFunc: func() (string, error) { - return promptUsername, nil - }, - ReadLineMaskedFunc: func() (string, error) { - return promptPassword, nil - }, - } } func (suite *LoginCredentialsManagerTestSuite) SetupTest() { suite.require = require.New(suite.T()) suite.clearCCEnvVars() suite.clearCPEnvVars() + ctrl := gomock.NewController(suite.T()) + suite.prompt = mock.NewMockPrompt(ctrl) + suite.prompt.EXPECT().ReadLine().Return(promptUsername, nil).AnyTimes() + suite.prompt.EXPECT().ReadLineMasked().Return(promptPassword, nil).AnyTimes() suite.loginCredentialsManager = NewLoginCredentialsManager(suite.prompt, suite.ccloudClient) } diff --git a/pkg/auth/login_organization_manager.go b/pkg/auth/login_organization_manager.go index 0874143ae7..ad9188ca40 100644 --- a/pkg/auth/login_organization_manager.go +++ b/pkg/auth/login_organization_manager.go @@ -1,4 +1,4 @@ -//go:generate mocker --dst ../../mock/login_organization_manager.go --pkg mock --selfpkg github.com/confluentinc/cli/v4 login_organization_manager.go LoginOrganizationManager --prefix "" +//go:generate go run go.uber.org/mock/mockgen -typed -destination=../../mock/login_organization_manager.go -package=mock github.com/confluentinc/cli/v4/pkg/auth LoginOrganizationManager package auth import ( diff --git a/pkg/auth/mds_client.go b/pkg/auth/mds_client.go index 4bfa8fd8de..d59f201741 100644 --- a/pkg/auth/mds_client.go +++ b/pkg/auth/mds_client.go @@ -1,4 +1,4 @@ -//go:generate go run github.com/travisjeffery/mocker/cmd/mocker --dst ../../mock/auth_mds_client.go --pkg mock --selfpkg github.com/confluentinc/cli/v4 mds_client.go MDSClientManager +//go:generate go run go.uber.org/mock/mockgen -typed -destination=../../mock/auth_mds_client.go -package=mock github.com/confluentinc/cli/v4/pkg/auth MDSClientManager package auth import ( diff --git a/pkg/cmd/prerunner_test.go b/pkg/cmd/prerunner_test.go index 45fff4770b..c274dc28c8 100644 --- a/pkg/cmd/prerunner_test.go +++ b/pkg/cmd/prerunner_test.go @@ -2,12 +2,12 @@ package cmd_test import ( "bytes" - "context" "fmt" "testing" "github.com/spf13/cobra" "github.com/stretchr/testify/require" + "go.uber.org/mock/gomock" ccloudv1 "github.com/confluentinc/ccloud-sdk-go-v1-public" ccloudv1mock "github.com/confluentinc/ccloud-sdk-go-v1-public/mock" @@ -44,64 +44,43 @@ const ( "WF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" ) -var ( - mockLoginCredentialsManager = &climock.LoginCredentialsManager{ - GetCloudCredentialsFromEnvVarFunc: func(_ string) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - GetPrerunCredentialsFromConfigFunc: func(_ *config.Config) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - GetCloudCredentialsFromPromptFunc: func(_ string) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - GetCredentialsFromKeychainFunc: func(_ bool, _, _ string) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - GetCredentialsFromConfigFunc: func(_ *config.Config, _ config.MachineParams) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - } - AuthTokenHandler = &climock.AuthTokenHandler{ - GetCCloudTokensFunc: func(_ pauth.CCloudClientFactory, _ string, _ *pauth.Credentials, _ bool, _ string) (string, string, error) { - return "", "", nil - }, - GetConfluentTokenFunc: func(_ *mdsv1.APIClient, _ *pauth.Credentials, _ bool) (string, string, error) { - return "", "", nil - }, - } -) +func getPreRunBase(ctrl *gomock.Controller) *pcmd.PreRun { + loginCredentialsManager := climock.NewMockLoginCredentialsManager(ctrl) + loginCredentialsManager.EXPECT().GetCloudCredentialsFromEnvVar(gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + loginCredentialsManager.EXPECT().GetPrerunCredentialsFromConfig(gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + loginCredentialsManager.EXPECT().GetCloudCredentialsFromPrompt(gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + loginCredentialsManager.EXPECT().GetCredentialsFromKeychain(gomock.Any(), gomock.Any(), gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + loginCredentialsManager.EXPECT().GetCredentialsFromConfig(gomock.Any(), gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + + authTokenHandler := climock.NewMockAuthTokenHandler(ctrl) + authTokenHandler.EXPECT().GetCCloudTokens(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return("", "", nil).AnyTimes() + authTokenHandler.EXPECT().GetConfluentToken(gomock.Any(), gomock.Any(), gomock.Any()).Return("", "", nil).AnyTimes() + + ccloudClientFactory := climock.NewMockCCloudClientFactory(ctrl) + ccloudClientFactory.EXPECT().JwtHTTPClientFactory(gomock.Any(), gomock.Any(), gomock.Any()).Return(&ccloudv1.Client{}).AnyTimes() + ccloudClientFactory.EXPECT().AnonHTTPClientFactory(gomock.Any()).Return(&ccloudv1.Client{}).AnyTimes() + + mdsClientManager := climock.NewMockMDSClientManager(ctrl) + mdsClientManager.EXPECT().GetMDSClient(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(&mdsv1.APIClient{}, nil).AnyTimes() -func getPreRunBase() *pcmd.PreRun { return &pcmd.PreRun{ - Config: config.AuthenticatedCloudConfigMock(), - Version: pmock.NewVersionMock(), - CCloudClientFactory: &climock.CCloudClientFactory{ - JwtHTTPClientFactoryFunc: func(ctx context.Context, jwt, baseURL string) *ccloudv1.Client { - return &ccloudv1.Client{} - }, - AnonHTTPClientFactoryFunc: func(baseURL string) *ccloudv1.Client { - return &ccloudv1.Client{} - }, - }, - MDSClientManager: &climock.MDSClientManager{ - GetMDSClientFunc: func(_, _, _, _ string, _ bool) (*mdsv1.APIClient, error) { - return &mdsv1.APIClient{}, nil - }, - }, - LoginCredentialsManager: mockLoginCredentialsManager, + Config: config.AuthenticatedCloudConfigMock(), + Version: pmock.NewVersionMock(), + CCloudClientFactory: ccloudClientFactory, + MDSClientManager: mdsClientManager, + LoginCredentialsManager: loginCredentialsManager, JWTValidator: jwt.NewValidator(), - AuthTokenHandler: AuthTokenHandler, + AuthTokenHandler: authTokenHandler, } } @@ -118,7 +97,8 @@ func TestPreRun_Anonymous_SetLoggingLevel(t *testing.T) { } for flags, level := range tests { - r := getPreRunBase() + ctrl := gomock.NewController(t) + r := getPreRunBase(ctrl) cmd := &cobra.Command{Run: func(cmd *cobra.Command, args []string) {}} cmd.Flags().CountP("verbose", "v", "Increase verbosity") @@ -136,7 +116,8 @@ func TestPreRun_TokenExpires(t *testing.T) { cfg := config.AuthenticatedCloudConfigMock() cfg.Context().State.AuthToken = expiredAuthTokenForDevCloud - r := getPreRunBase() + ctrl := gomock.NewController(t) + r := getPreRunBase(ctrl) r.Config = cfg root := &cobra.Command{Run: func(cmd *cobra.Command, args []string) {}} @@ -205,46 +186,33 @@ func TestUpdateToken(t *testing.T) { cfg.Context().State.AuthToken = test.authToken - r := getPreRunBase() + ctrl := gomock.NewController(t) + r := getPreRunBase(ctrl) r.Config = cfg - r.LoginCredentialsManager = &climock.LoginCredentialsManager{ - GetPrerunCredentialsFromConfigFunc: func(_ *config.Config) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - GetCredentialsFromKeychainFunc: func(_ bool, _, _ string) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - GetCredentialsFromConfigFunc: func(_ *config.Config, _ config.MachineParams) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return &pauth.Credentials{Username: "username", Password: "password"}, nil - } - }, - GetCloudCredentialsFromEnvVarFunc: func(_ string) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - GetOnPremSsoCredentialsFromConfigFunc: func(_ *config.Config, _ bool) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - GetOnPremPrerunCredentialsFromEnvVarFunc: func() func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - GetOnPremCredentialsFromEnvVarFunc: func() func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - } + loginCredentialsManager := climock.NewMockLoginCredentialsManager(ctrl) + loginCredentialsManager.EXPECT().GetPrerunCredentialsFromConfig(gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + loginCredentialsManager.EXPECT().GetCredentialsFromKeychain(gomock.Any(), gomock.Any(), gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + loginCredentialsManager.EXPECT().GetCredentialsFromConfig(gomock.Any(), gomock.Any()).Return(func() (*pauth.Credentials, error) { + return &pauth.Credentials{Username: "username", Password: "password"}, nil + }).AnyTimes() + loginCredentialsManager.EXPECT().GetCloudCredentialsFromEnvVar(gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + loginCredentialsManager.EXPECT().GetOnPremSsoCredentialsFromConfig(gomock.Any(), gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + loginCredentialsManager.EXPECT().GetOnPremPrerunCredentialsFromEnvVar().Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + loginCredentialsManager.EXPECT().GetOnPremCredentialsFromEnvVar().Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + r.LoginCredentialsManager = loginCredentialsManager root := &cobra.Command{Run: func(cmd *cobra.Command, args []string) {}} var rootCmd *pcmd.AuthenticatedCLICommand @@ -361,68 +329,53 @@ func TestPrerun_AutoLogin(t *testing.T) { err := pauth.PersistLogout(cfg) require.NoError(t, err) - r := getPreRunBase() + ctrl := gomock.NewController(t) + r := getPreRunBase(ctrl) r.Config = cfg - r.CCloudClientFactory = &climock.CCloudClientFactory{ - JwtHTTPClientFactoryFunc: func(ctx context.Context, jwt, baseURL string) *ccloudv1.Client { - return &ccloudv1.Client{Auth: &ccloudv1mock.Auth{ - UserFunc: func() (*ccloudv1.GetMeReply, error) { - return &ccloudv1.GetMeReply{ - User: &ccloudv1.User{Id: 23}, - Organization: &ccloudv1.Organization{ResourceId: "o-123"}, - Accounts: []*ccloudv1.Account{{Id: "env-596", Name: "Default"}}, - }, nil - }, - }} - }, - AnonHTTPClientFactoryFunc: func(baseURL string) *ccloudv1.Client { - return &ccloudv1.Client{} - }, - } - r.AuthTokenHandler = &climock.AuthTokenHandler{ - GetCCloudTokensFunc: func(_ pauth.CCloudClientFactory, _ string, _ *pauth.Credentials, _ bool, _ string) (string, string, error) { - return validAuthToken, "", nil - }, - GetConfluentTokenFunc: func(_ *mdsv1.APIClient, _ *pauth.Credentials, _ bool) (string, string, error) { - return validAuthToken, "", nil + + ccloudClientFactory := climock.NewMockCCloudClientFactory(ctrl) + ccloudClientFactory.EXPECT().JwtHTTPClientFactory(gomock.Any(), gomock.Any(), gomock.Any()).Return(&ccloudv1.Client{Auth: &ccloudv1mock.Auth{ + UserFunc: func() (*ccloudv1.GetMeReply, error) { + return &ccloudv1.GetMeReply{ + User: &ccloudv1.User{Id: 23}, + Organization: &ccloudv1.Organization{ResourceId: "o-123"}, + Accounts: []*ccloudv1.Account{{Id: "env-596", Name: "Default"}}, + }, nil }, - } + }}).AnyTimes() + ccloudClientFactory.EXPECT().AnonHTTPClientFactory(gomock.Any()).Return(&ccloudv1.Client{}).AnyTimes() + r.CCloudClientFactory = ccloudClientFactory + + authTokenHandler := climock.NewMockAuthTokenHandler(ctrl) + authTokenHandler.EXPECT().GetCCloudTokens(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(validAuthToken, "", nil).AnyTimes() + authTokenHandler.EXPECT().GetConfluentToken(gomock.Any(), gomock.Any(), gomock.Any()).Return(validAuthToken, "", nil).AnyTimes() + r.AuthTokenHandler = authTokenHandler var ccloudEnvVarCalled bool var ccloudConfigCalled bool var ccloudKeychainCalled bool var confluentEnvVarCalled bool - r.LoginCredentialsManager = &climock.LoginCredentialsManager{ - GetCloudCredentialsFromEnvVarFunc: func(_ string) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - ccloudEnvVarCalled = true - return test.envVarReturn.creds, test.envVarReturn.err - } - }, - GetPrerunCredentialsFromConfigFunc: func(_ *config.Config) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - ccloudConfigCalled = true - return test.configReturn.creds, test.configReturn.err - } - }, - GetOnPremPrerunCredentialsFromEnvVarFunc: func() func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - confluentEnvVarCalled = true - return test.envVarReturn.creds, test.envVarReturn.err - } - }, - GetCredentialsFromConfigFunc: func(_ *config.Config, _ config.MachineParams) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - GetCredentialsFromKeychainFunc: func(_ bool, _, _ string) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - ccloudKeychainCalled = true - return test.keychainReturn.creds, test.keychainReturn.err - } - }, - } + loginCredentialsManager := climock.NewMockLoginCredentialsManager(ctrl) + loginCredentialsManager.EXPECT().GetCloudCredentialsFromEnvVar(gomock.Any()).Return(func() (*pauth.Credentials, error) { + ccloudEnvVarCalled = true + return test.envVarReturn.creds, test.envVarReturn.err + }).AnyTimes() + loginCredentialsManager.EXPECT().GetPrerunCredentialsFromConfig(gomock.Any()).Return(func() (*pauth.Credentials, error) { + ccloudConfigCalled = true + return test.configReturn.creds, test.configReturn.err + }).AnyTimes() + loginCredentialsManager.EXPECT().GetOnPremPrerunCredentialsFromEnvVar().Return(func() (*pauth.Credentials, error) { + confluentEnvVarCalled = true + return test.envVarReturn.creds, test.envVarReturn.err + }).AnyTimes() + loginCredentialsManager.EXPECT().GetCredentialsFromConfig(gomock.Any(), gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + loginCredentialsManager.EXPECT().GetCredentialsFromKeychain(gomock.Any(), gomock.Any(), gomock.Any()).Return(func() (*pauth.Credentials, error) { + ccloudKeychainCalled = true + return test.keychainReturn.creds, test.keychainReturn.err + }).AnyTimes() + r.LoginCredentialsManager = loginCredentialsManager root := &cobra.Command{ Run: func(cmd *cobra.Command, args []string) {}, @@ -466,51 +419,43 @@ func TestPrerun_ReLoginToLastOrgUsed(t *testing.T) { Username: "username", Password: "password", } - r := getPreRunBase() - r.CCloudClientFactory = &climock.CCloudClientFactory{ - JwtHTTPClientFactoryFunc: func(ctx context.Context, jwt, baseURL string) *ccloudv1.Client { - return &ccloudv1.Client{Auth: &ccloudv1mock.Auth{ - UserFunc: func() (*ccloudv1.GetMeReply, error) { - return &ccloudv1.GetMeReply{ - User: &ccloudv1.User{Id: 23}, - Organization: &ccloudv1.Organization{ResourceId: "o-123"}, - Accounts: []*ccloudv1.Account{{Id: "env-596", Name: "Default"}}, - }, nil - }, - }} - }, - AnonHTTPClientFactoryFunc: func(baseURL string) *ccloudv1.Client { - return &ccloudv1.Client{} - }, - } - r.AuthTokenHandler = &climock.AuthTokenHandler{ - GetCCloudTokensFunc: func(_ pauth.CCloudClientFactory, _ string, _ *pauth.Credentials, _ bool, organizationId string) (string, string, error) { - require.Equal(t, "o-555", organizationId) - return validAuthToken, "", nil - }, - } - r.LoginCredentialsManager = &climock.LoginCredentialsManager{ - GetCloudCredentialsFromEnvVarFunc: func(_ string) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return ccloudCreds, nil - } - }, - GetPrerunCredentialsFromConfigFunc: func(_ *config.Config) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - GetCredentialsFromConfigFunc: func(_ *config.Config, _ config.MachineParams) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - GetCredentialsFromKeychainFunc: func(_ bool, _, _ string) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - } + ctrl := gomock.NewController(t) + r := getPreRunBase(ctrl) + + ccloudClientFactory := climock.NewMockCCloudClientFactory(ctrl) + ccloudClientFactory.EXPECT().JwtHTTPClientFactory(gomock.Any(), gomock.Any(), gomock.Any()).Return(&ccloudv1.Client{Auth: &ccloudv1mock.Auth{ + UserFunc: func() (*ccloudv1.GetMeReply, error) { + return &ccloudv1.GetMeReply{ + User: &ccloudv1.User{Id: 23}, + Organization: &ccloudv1.Organization{ResourceId: "o-123"}, + Accounts: []*ccloudv1.Account{{Id: "env-596", Name: "Default"}}, + }, nil + }, + }}).AnyTimes() + ccloudClientFactory.EXPECT().AnonHTTPClientFactory(gomock.Any()).Return(&ccloudv1.Client{}).AnyTimes() + r.CCloudClientFactory = ccloudClientFactory + + authTokenHandler := climock.NewMockAuthTokenHandler(ctrl) + authTokenHandler.EXPECT().GetCCloudTokens(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(_ pauth.CCloudClientFactory, _ string, _ *pauth.Credentials, _ bool, organizationId string) (string, string, error) { + require.Equal(t, "o-555", organizationId) + return validAuthToken, "", nil + }).AnyTimes() + r.AuthTokenHandler = authTokenHandler + + loginCredentialsManager := climock.NewMockLoginCredentialsManager(ctrl) + loginCredentialsManager.EXPECT().GetCloudCredentialsFromEnvVar(gomock.Any()).Return(func() (*pauth.Credentials, error) { + return ccloudCreds, nil + }).AnyTimes() + loginCredentialsManager.EXPECT().GetPrerunCredentialsFromConfig(gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + loginCredentialsManager.EXPECT().GetCredentialsFromConfig(gomock.Any(), gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + loginCredentialsManager.EXPECT().GetCredentialsFromKeychain(gomock.Any(), gomock.Any(), gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() + r.LoginCredentialsManager = loginCredentialsManager cfg := config.AuthenticatedToOrgCloudConfigMock(555, "o-555") cfg.Context().Platform = &config.Platform{Name: "confluent.cloud", Server: "https://confluent.cloud"} @@ -552,21 +497,17 @@ func TestPrerun_AutoLoginNotTriggeredIfLoggedIn(t *testing.T) { cfg.Context().Platform.Server = "https://confluent.cloud" var envVarCalled bool - mockLoginCredentialsManager := &climock.LoginCredentialsManager{ - GetCloudCredentialsFromEnvVarFunc: func(_ string) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - envVarCalled = true - return nil, nil - } - }, - GetCredentialsFromKeychainFunc: func(_ bool, _, _ string) func() (*pauth.Credentials, error) { - return func() (*pauth.Credentials, error) { - return nil, nil - } - }, - } + ctrl := gomock.NewController(t) + mockLoginCredentialsManager := climock.NewMockLoginCredentialsManager(ctrl) + mockLoginCredentialsManager.EXPECT().GetCloudCredentialsFromEnvVar(gomock.Any()).Return(func() (*pauth.Credentials, error) { + envVarCalled = true + return nil, nil + }).AnyTimes() + mockLoginCredentialsManager.EXPECT().GetCredentialsFromKeychain(gomock.Any(), gomock.Any(), gomock.Any()).Return(func() (*pauth.Credentials, error) { + return nil, nil + }).AnyTimes() - r := getPreRunBase() + r := getPreRunBase(ctrl) r.Config = cfg r.LoginCredentialsManager = mockLoginCredentialsManager @@ -593,7 +534,8 @@ func TestPrerun_AutoLoginNotTriggeredIfLoggedIn(t *testing.T) { func TestInitializeOnPremKafkaRest(t *testing.T) { cfg := config.AuthenticatedOnPremConfigMock() cfg.Context().State.AuthToken = validAuthToken - r := getPreRunBase() + ctrl := gomock.NewController(t) + r := getPreRunBase(ctrl) r.Config = cfg cobraCmd := &cobra.Command{Use: "test"} cobraCmd.Flags().CountP("verbose", "v", "Increase verbosity") diff --git a/pkg/featureflags/feature_flags.go b/pkg/featureflags/feature_flags.go index 06660dc9d0..d8262c14d8 100644 --- a/pkg/featureflags/feature_flags.go +++ b/pkg/featureflags/feature_flags.go @@ -1,5 +1,3 @@ -//go:generate go run github.com/travisjeffery/mocker/cmd/mocker --prefix "" --dst ../mock/launch_darkly.go --pkg mock --selfpkg github.com/confluentinc/cli/v4 launch_darkly.go LaunchDarklyManager - package featureflags import ( diff --git a/pkg/flink/test/mock/application_controller_mock.go b/pkg/flink/test/mock/application_controller_mock.go index 5a7c353932..a7e72958c3 100644 --- a/pkg/flink/test/mock/application_controller_mock.go +++ b/pkg/flink/test/mock/application_controller_mock.go @@ -20,6 +20,7 @@ import ( type MockApplicationControllerInterface struct { ctrl *gomock.Controller recorder *MockApplicationControllerInterfaceMockRecorder + isgomock struct{} } // MockApplicationControllerInterfaceMockRecorder is the mock recorder for MockApplicationControllerInterface. diff --git a/pkg/flink/test/mock/cmf_client_mock.go b/pkg/flink/test/mock/cmf_client_mock.go index c9b7aa3524..360b140a88 100644 --- a/pkg/flink/test/mock/cmf_client_mock.go +++ b/pkg/flink/test/mock/cmf_client_mock.go @@ -3,7 +3,7 @@ // // Generated by this command: // -// mockgen -destination pkg/flink/test/mock/cmf_client_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink CmfClientInterface +// mockgen -destination cmf_client_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink CmfClientInterface // // Package mock is a generated GoMock package. @@ -115,10 +115,10 @@ func (mr *MockCmfClientInterfaceMockRecorder) GetStatementResults(ctx, environme } // GetSystemInformation mocks base method. -func (m *MockCmfClientInterface) GetSystemInformation(ctx context.Context) (map[string]interface{}, error) { +func (m *MockCmfClientInterface) GetSystemInformation(ctx context.Context) (map[string]any, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetSystemInformation", ctx) - ret0, _ := ret[0].(map[string]interface{}) + ret0, _ := ret[0].(map[string]any) ret1, _ := ret[1].(error) return ret0, ret1 } diff --git a/pkg/flink/test/mock/console_parser_mock.go b/pkg/flink/test/mock/console_parser_mock.go index be4a2082f4..fa1538cafc 100644 --- a/pkg/flink/test/mock/console_parser_mock.go +++ b/pkg/flink/test/mock/console_parser_mock.go @@ -20,6 +20,7 @@ import ( type MockConsoleParser struct { ctrl *gomock.Controller recorder *MockConsoleParserMockRecorder + isgomock struct{} } // MockConsoleParserMockRecorder is the mock recorder for MockConsoleParser. diff --git a/pkg/flink/test/mock/gateway_client_mock.go b/pkg/flink/test/mock/gateway_client_mock.go index 271848e385..9358c24f72 100644 --- a/pkg/flink/test/mock/gateway_client_mock.go +++ b/pkg/flink/test/mock/gateway_client_mock.go @@ -20,6 +20,7 @@ import ( type MockGatewayClientInterface struct { ctrl *gomock.Controller recorder *MockGatewayClientInterfaceMockRecorder + isgomock struct{} } // MockGatewayClientInterfaceMockRecorder is the mock recorder for MockGatewayClientInterface. @@ -40,61 +41,61 @@ func (m *MockGatewayClientInterface) EXPECT() *MockGatewayClientInterfaceMockRec } // CreateConnection mocks base method. -func (m *MockGatewayClientInterface) CreateConnection(arg0 v1.SqlV1Connection, arg1, arg2 string) (v1.SqlV1Connection, error) { +func (m *MockGatewayClientInterface) CreateConnection(connection v1.SqlV1Connection, environmentId, orgId string) (v1.SqlV1Connection, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CreateConnection", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "CreateConnection", connection, environmentId, orgId) ret0, _ := ret[0].(v1.SqlV1Connection) ret1, _ := ret[1].(error) return ret0, ret1 } // CreateConnection indicates an expected call of CreateConnection. -func (mr *MockGatewayClientInterfaceMockRecorder) CreateConnection(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockGatewayClientInterfaceMockRecorder) CreateConnection(connection, environmentId, orgId any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateConnection", reflect.TypeOf((*MockGatewayClientInterface)(nil).CreateConnection), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateConnection", reflect.TypeOf((*MockGatewayClientInterface)(nil).CreateConnection), connection, environmentId, orgId) } // CreateStatement mocks base method. -func (m *MockGatewayClientInterface) CreateStatement(arg0 v1.SqlV1Statement, arg1, arg2, arg3 string) (v1.SqlV1Statement, error) { +func (m *MockGatewayClientInterface) CreateStatement(statement v1.SqlV1Statement, principal, environmentId, orgId string) (v1.SqlV1Statement, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CreateStatement", arg0, arg1, arg2, arg3) + ret := m.ctrl.Call(m, "CreateStatement", statement, principal, environmentId, orgId) ret0, _ := ret[0].(v1.SqlV1Statement) ret1, _ := ret[1].(error) return ret0, ret1 } // CreateStatement indicates an expected call of CreateStatement. -func (mr *MockGatewayClientInterfaceMockRecorder) CreateStatement(arg0, arg1, arg2, arg3 any) *gomock.Call { +func (mr *MockGatewayClientInterfaceMockRecorder) CreateStatement(statement, principal, environmentId, orgId any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateStatement", reflect.TypeOf((*MockGatewayClientInterface)(nil).CreateStatement), arg0, arg1, arg2, arg3) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateStatement", reflect.TypeOf((*MockGatewayClientInterface)(nil).CreateStatement), statement, principal, environmentId, orgId) } // DeleteConnection mocks base method. -func (m *MockGatewayClientInterface) DeleteConnection(arg0, arg1, arg2 string) error { +func (m *MockGatewayClientInterface) DeleteConnection(environmentId, connectionName, orgId string) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DeleteConnection", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "DeleteConnection", environmentId, connectionName, orgId) ret0, _ := ret[0].(error) return ret0 } // DeleteConnection indicates an expected call of DeleteConnection. -func (mr *MockGatewayClientInterfaceMockRecorder) DeleteConnection(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockGatewayClientInterfaceMockRecorder) DeleteConnection(environmentId, connectionName, orgId any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteConnection", reflect.TypeOf((*MockGatewayClientInterface)(nil).DeleteConnection), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteConnection", reflect.TypeOf((*MockGatewayClientInterface)(nil).DeleteConnection), environmentId, connectionName, orgId) } // DeleteStatement mocks base method. -func (m *MockGatewayClientInterface) DeleteStatement(arg0, arg1, arg2 string) error { +func (m *MockGatewayClientInterface) DeleteStatement(environmentId, statementName, orgId string) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DeleteStatement", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "DeleteStatement", environmentId, statementName, orgId) ret0, _ := ret[0].(error) return ret0 } // DeleteStatement indicates an expected call of DeleteStatement. -func (mr *MockGatewayClientInterfaceMockRecorder) DeleteStatement(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockGatewayClientInterfaceMockRecorder) DeleteStatement(environmentId, statementName, orgId any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteStatement", reflect.TypeOf((*MockGatewayClientInterface)(nil).DeleteStatement), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteStatement", reflect.TypeOf((*MockGatewayClientInterface)(nil).DeleteStatement), environmentId, statementName, orgId) } // GetAuthToken mocks base method. @@ -112,119 +113,119 @@ func (mr *MockGatewayClientInterfaceMockRecorder) GetAuthToken() *gomock.Call { } // GetConnection mocks base method. -func (m *MockGatewayClientInterface) GetConnection(arg0, arg1, arg2 string) (v1.SqlV1Connection, error) { +func (m *MockGatewayClientInterface) GetConnection(environmentId, connectionName, orgId string) (v1.SqlV1Connection, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetConnection", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "GetConnection", environmentId, connectionName, orgId) ret0, _ := ret[0].(v1.SqlV1Connection) ret1, _ := ret[1].(error) return ret0, ret1 } // GetConnection indicates an expected call of GetConnection. -func (mr *MockGatewayClientInterfaceMockRecorder) GetConnection(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockGatewayClientInterfaceMockRecorder) GetConnection(environmentId, connectionName, orgId any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetConnection", reflect.TypeOf((*MockGatewayClientInterface)(nil).GetConnection), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetConnection", reflect.TypeOf((*MockGatewayClientInterface)(nil).GetConnection), environmentId, connectionName, orgId) } // GetExceptions mocks base method. -func (m *MockGatewayClientInterface) GetExceptions(arg0, arg1, arg2 string) ([]v1.SqlV1StatementException, error) { +func (m *MockGatewayClientInterface) GetExceptions(environmentId, statementId, orgId string) ([]v1.SqlV1StatementException, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetExceptions", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "GetExceptions", environmentId, statementId, orgId) ret0, _ := ret[0].([]v1.SqlV1StatementException) ret1, _ := ret[1].(error) return ret0, ret1 } // GetExceptions indicates an expected call of GetExceptions. -func (mr *MockGatewayClientInterfaceMockRecorder) GetExceptions(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockGatewayClientInterfaceMockRecorder) GetExceptions(environmentId, statementId, orgId any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetExceptions", reflect.TypeOf((*MockGatewayClientInterface)(nil).GetExceptions), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetExceptions", reflect.TypeOf((*MockGatewayClientInterface)(nil).GetExceptions), environmentId, statementId, orgId) } // GetStatement mocks base method. -func (m *MockGatewayClientInterface) GetStatement(arg0, arg1, arg2 string) (v1.SqlV1Statement, error) { +func (m *MockGatewayClientInterface) GetStatement(environmentId, statementName, orgId string) (v1.SqlV1Statement, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetStatement", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "GetStatement", environmentId, statementName, orgId) ret0, _ := ret[0].(v1.SqlV1Statement) ret1, _ := ret[1].(error) return ret0, ret1 } // GetStatement indicates an expected call of GetStatement. -func (mr *MockGatewayClientInterfaceMockRecorder) GetStatement(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockGatewayClientInterfaceMockRecorder) GetStatement(environmentId, statementName, orgId any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStatement", reflect.TypeOf((*MockGatewayClientInterface)(nil).GetStatement), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStatement", reflect.TypeOf((*MockGatewayClientInterface)(nil).GetStatement), environmentId, statementName, orgId) } // GetStatementResults mocks base method. -func (m *MockGatewayClientInterface) GetStatementResults(arg0, arg1, arg2, arg3 string) (v1.SqlV1StatementResult, error) { +func (m *MockGatewayClientInterface) GetStatementResults(environmentId, statementId, orgId, pageToken string) (v1.SqlV1StatementResult, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetStatementResults", arg0, arg1, arg2, arg3) + ret := m.ctrl.Call(m, "GetStatementResults", environmentId, statementId, orgId, pageToken) ret0, _ := ret[0].(v1.SqlV1StatementResult) ret1, _ := ret[1].(error) return ret0, ret1 } // GetStatementResults indicates an expected call of GetStatementResults. -func (mr *MockGatewayClientInterfaceMockRecorder) GetStatementResults(arg0, arg1, arg2, arg3 any) *gomock.Call { +func (mr *MockGatewayClientInterfaceMockRecorder) GetStatementResults(environmentId, statementId, orgId, pageToken any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStatementResults", reflect.TypeOf((*MockGatewayClientInterface)(nil).GetStatementResults), arg0, arg1, arg2, arg3) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStatementResults", reflect.TypeOf((*MockGatewayClientInterface)(nil).GetStatementResults), environmentId, statementId, orgId, pageToken) } // ListConnections mocks base method. -func (m *MockGatewayClientInterface) ListConnections(arg0, arg1, arg2 string) ([]v1.SqlV1Connection, error) { +func (m *MockGatewayClientInterface) ListConnections(environmentId, orgId, connectionType string) ([]v1.SqlV1Connection, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ListConnections", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "ListConnections", environmentId, orgId, connectionType) ret0, _ := ret[0].([]v1.SqlV1Connection) ret1, _ := ret[1].(error) return ret0, ret1 } // ListConnections indicates an expected call of ListConnections. -func (mr *MockGatewayClientInterfaceMockRecorder) ListConnections(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockGatewayClientInterfaceMockRecorder) ListConnections(environmentId, orgId, connectionType any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListConnections", reflect.TypeOf((*MockGatewayClientInterface)(nil).ListConnections), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListConnections", reflect.TypeOf((*MockGatewayClientInterface)(nil).ListConnections), environmentId, orgId, connectionType) } // ListStatements mocks base method. -func (m *MockGatewayClientInterface) ListStatements(arg0, arg1, arg2 string) ([]v1.SqlV1Statement, error) { +func (m *MockGatewayClientInterface) ListStatements(environmentId, orgId, computePoolId string) ([]v1.SqlV1Statement, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ListStatements", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "ListStatements", environmentId, orgId, computePoolId) ret0, _ := ret[0].([]v1.SqlV1Statement) ret1, _ := ret[1].(error) return ret0, ret1 } // ListStatements indicates an expected call of ListStatements. -func (mr *MockGatewayClientInterfaceMockRecorder) ListStatements(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockGatewayClientInterfaceMockRecorder) ListStatements(environmentId, orgId, computePoolId any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListStatements", reflect.TypeOf((*MockGatewayClientInterface)(nil).ListStatements), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListStatements", reflect.TypeOf((*MockGatewayClientInterface)(nil).ListStatements), environmentId, orgId, computePoolId) } // UpdateConnection mocks base method. -func (m *MockGatewayClientInterface) UpdateConnection(arg0, arg1, arg2 string, arg3 v1.SqlV1Connection) error { +func (m *MockGatewayClientInterface) UpdateConnection(environmentId, connectionName, organizationId string, connection v1.SqlV1Connection) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "UpdateConnection", arg0, arg1, arg2, arg3) + ret := m.ctrl.Call(m, "UpdateConnection", environmentId, connectionName, organizationId, connection) ret0, _ := ret[0].(error) return ret0 } // UpdateConnection indicates an expected call of UpdateConnection. -func (mr *MockGatewayClientInterfaceMockRecorder) UpdateConnection(arg0, arg1, arg2, arg3 any) *gomock.Call { +func (mr *MockGatewayClientInterfaceMockRecorder) UpdateConnection(environmentId, connectionName, organizationId, connection any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateConnection", reflect.TypeOf((*MockGatewayClientInterface)(nil).UpdateConnection), arg0, arg1, arg2, arg3) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateConnection", reflect.TypeOf((*MockGatewayClientInterface)(nil).UpdateConnection), environmentId, connectionName, organizationId, connection) } // UpdateStatement mocks base method. -func (m *MockGatewayClientInterface) UpdateStatement(arg0, arg1, arg2 string, arg3 v1.SqlV1Statement) error { +func (m *MockGatewayClientInterface) UpdateStatement(environmentId, statementName, orgId string, statement v1.SqlV1Statement) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "UpdateStatement", arg0, arg1, arg2, arg3) + ret := m.ctrl.Call(m, "UpdateStatement", environmentId, statementName, orgId, statement) ret0, _ := ret[0].(error) return ret0 } // UpdateStatement indicates an expected call of UpdateStatement. -func (mr *MockGatewayClientInterfaceMockRecorder) UpdateStatement(arg0, arg1, arg2, arg3 any) *gomock.Call { +func (mr *MockGatewayClientInterfaceMockRecorder) UpdateStatement(environmentId, statementName, orgId, statement any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateStatement", reflect.TypeOf((*MockGatewayClientInterface)(nil).UpdateStatement), arg0, arg1, arg2, arg3) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateStatement", reflect.TypeOf((*MockGatewayClientInterface)(nil).UpdateStatement), environmentId, statementName, orgId, statement) } diff --git a/pkg/flink/test/mock/input_controller_mock.go b/pkg/flink/test/mock/input_controller_mock.go index 32a8a98eb2..566a9f56b6 100644 --- a/pkg/flink/test/mock/input_controller_mock.go +++ b/pkg/flink/test/mock/input_controller_mock.go @@ -20,6 +20,7 @@ import ( type MockInputControllerInterface struct { ctrl *gomock.Controller recorder *MockInputControllerInterfaceMockRecorder + isgomock struct{} } // MockInputControllerInterfaceMockRecorder is the mock recorder for MockInputControllerInterface. @@ -96,29 +97,29 @@ func (mr *MockInputControllerInterfaceMockRecorder) HasUserEnabledReverseSearch( } // HasUserInitiatedExit mocks base method. -func (m *MockInputControllerInterface) HasUserInitiatedExit(arg0 string) bool { +func (m *MockInputControllerInterface) HasUserInitiatedExit(userInput string) bool { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "HasUserInitiatedExit", arg0) + ret := m.ctrl.Call(m, "HasUserInitiatedExit", userInput) ret0, _ := ret[0].(bool) return ret0 } // HasUserInitiatedExit indicates an expected call of HasUserInitiatedExit. -func (mr *MockInputControllerInterfaceMockRecorder) HasUserInitiatedExit(arg0 any) *gomock.Call { +func (mr *MockInputControllerInterfaceMockRecorder) HasUserInitiatedExit(userInput any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasUserInitiatedExit", reflect.TypeOf((*MockInputControllerInterface)(nil).HasUserInitiatedExit), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasUserInitiatedExit", reflect.TypeOf((*MockInputControllerInterface)(nil).HasUserInitiatedExit), userInput) } // SetDiagnostics mocks base method. -func (m *MockInputControllerInterface) SetDiagnostics(arg0 []lsp.Diagnostic) { +func (m *MockInputControllerInterface) SetDiagnostics(diagnostics []lsp.Diagnostic) { m.ctrl.T.Helper() - m.ctrl.Call(m, "SetDiagnostics", arg0) + m.ctrl.Call(m, "SetDiagnostics", diagnostics) } // SetDiagnostics indicates an expected call of SetDiagnostics. -func (mr *MockInputControllerInterfaceMockRecorder) SetDiagnostics(arg0 any) *gomock.Call { +func (mr *MockInputControllerInterfaceMockRecorder) SetDiagnostics(diagnostics any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetDiagnostics", reflect.TypeOf((*MockInputControllerInterface)(nil).SetDiagnostics), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetDiagnostics", reflect.TypeOf((*MockInputControllerInterface)(nil).SetDiagnostics), diagnostics) } // StartReverseSearch mocks base method. diff --git a/pkg/flink/test/mock/json_rpc2_conn.go b/pkg/flink/test/mock/json_rpc2_conn.go index 26a69e15d4..60be23fbe6 100644 --- a/pkg/flink/test/mock/json_rpc2_conn.go +++ b/pkg/flink/test/mock/json_rpc2_conn.go @@ -21,6 +21,7 @@ import ( type MockJSONRpcConn struct { ctrl *gomock.Controller recorder *MockJSONRpcConnMockRecorder + isgomock struct{} } // MockJSONRpcConnMockRecorder is the mock recorder for MockJSONRpcConn. @@ -41,10 +42,10 @@ func (m *MockJSONRpcConn) EXPECT() *MockJSONRpcConnMockRecorder { } // Call mocks base method. -func (m *MockJSONRpcConn) Call(arg0 context.Context, arg1 string, arg2, arg3 any, arg4 ...jsonrpc2.CallOption) error { +func (m *MockJSONRpcConn) Call(ctx context.Context, method string, params, result any, opts ...jsonrpc2.CallOption) error { m.ctrl.T.Helper() - varargs := []any{arg0, arg1, arg2, arg3} - for _, a := range arg4 { + varargs := []any{ctx, method, params, result} + for _, a := range opts { varargs = append(varargs, a) } ret := m.ctrl.Call(m, "Call", varargs...) @@ -53,9 +54,9 @@ func (m *MockJSONRpcConn) Call(arg0 context.Context, arg1 string, arg2, arg3 any } // Call indicates an expected call of Call. -func (mr *MockJSONRpcConnMockRecorder) Call(arg0, arg1, arg2, arg3 any, arg4 ...any) *gomock.Call { +func (mr *MockJSONRpcConnMockRecorder) Call(ctx, method, params, result any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]any{arg0, arg1, arg2, arg3}, arg4...) + varargs := append([]any{ctx, method, params, result}, opts...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Call", reflect.TypeOf((*MockJSONRpcConn)(nil).Call), varargs...) } @@ -88,10 +89,10 @@ func (mr *MockJSONRpcConnMockRecorder) DisconnectNotify() *gomock.Call { } // DispatchCall mocks base method. -func (m *MockJSONRpcConn) DispatchCall(arg0 context.Context, arg1 string, arg2 any, arg3 ...jsonrpc2.CallOption) (jsonrpc2.Waiter, error) { +func (m *MockJSONRpcConn) DispatchCall(ctx context.Context, method string, params any, opts ...jsonrpc2.CallOption) (jsonrpc2.Waiter, error) { m.ctrl.T.Helper() - varargs := []any{arg0, arg1, arg2} - for _, a := range arg3 { + varargs := []any{ctx, method, params} + for _, a := range opts { varargs = append(varargs, a) } ret := m.ctrl.Call(m, "DispatchCall", varargs...) @@ -101,17 +102,17 @@ func (m *MockJSONRpcConn) DispatchCall(arg0 context.Context, arg1 string, arg2 a } // DispatchCall indicates an expected call of DispatchCall. -func (mr *MockJSONRpcConnMockRecorder) DispatchCall(arg0, arg1, arg2 any, arg3 ...any) *gomock.Call { +func (mr *MockJSONRpcConnMockRecorder) DispatchCall(ctx, method, params any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]any{arg0, arg1, arg2}, arg3...) + varargs := append([]any{ctx, method, params}, opts...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DispatchCall", reflect.TypeOf((*MockJSONRpcConn)(nil).DispatchCall), varargs...) } // Notify mocks base method. -func (m *MockJSONRpcConn) Notify(arg0 context.Context, arg1 string, arg2 any, arg3 ...jsonrpc2.CallOption) error { +func (m *MockJSONRpcConn) Notify(ctx context.Context, method string, params any, opts ...jsonrpc2.CallOption) error { m.ctrl.T.Helper() - varargs := []any{arg0, arg1, arg2} - for _, a := range arg3 { + varargs := []any{ctx, method, params} + for _, a := range opts { varargs = append(varargs, a) } ret := m.ctrl.Call(m, "Notify", varargs...) @@ -120,36 +121,36 @@ func (m *MockJSONRpcConn) Notify(arg0 context.Context, arg1 string, arg2 any, ar } // Notify indicates an expected call of Notify. -func (mr *MockJSONRpcConnMockRecorder) Notify(arg0, arg1, arg2 any, arg3 ...any) *gomock.Call { +func (mr *MockJSONRpcConnMockRecorder) Notify(ctx, method, params any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]any{arg0, arg1, arg2}, arg3...) + varargs := append([]any{ctx, method, params}, opts...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Notify", reflect.TypeOf((*MockJSONRpcConn)(nil).Notify), varargs...) } // ReplyWithError mocks base method. -func (m *MockJSONRpcConn) ReplyWithError(arg0 context.Context, arg1 jsonrpc2.ID, arg2 *jsonrpc2.Error) error { +func (m *MockJSONRpcConn) ReplyWithError(ctx context.Context, id jsonrpc2.ID, respErr *jsonrpc2.Error) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ReplyWithError", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "ReplyWithError", ctx, id, respErr) ret0, _ := ret[0].(error) return ret0 } // ReplyWithError indicates an expected call of ReplyWithError. -func (mr *MockJSONRpcConnMockRecorder) ReplyWithError(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockJSONRpcConnMockRecorder) ReplyWithError(ctx, id, respErr any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReplyWithError", reflect.TypeOf((*MockJSONRpcConn)(nil).ReplyWithError), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReplyWithError", reflect.TypeOf((*MockJSONRpcConn)(nil).ReplyWithError), ctx, id, respErr) } // SendResponse mocks base method. -func (m *MockJSONRpcConn) SendResponse(arg0 context.Context, arg1 *jsonrpc2.Response) error { +func (m *MockJSONRpcConn) SendResponse(ctx context.Context, resp *jsonrpc2.Response) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SendResponse", arg0, arg1) + ret := m.ctrl.Call(m, "SendResponse", ctx, resp) ret0, _ := ret[0].(error) return ret0 } // SendResponse indicates an expected call of SendResponse. -func (mr *MockJSONRpcConnMockRecorder) SendResponse(arg0, arg1 any) *gomock.Call { +func (mr *MockJSONRpcConnMockRecorder) SendResponse(ctx, resp any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendResponse", reflect.TypeOf((*MockJSONRpcConn)(nil).SendResponse), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendResponse", reflect.TypeOf((*MockJSONRpcConn)(nil).SendResponse), ctx, resp) } diff --git a/pkg/flink/test/mock/mock_generator.go b/pkg/flink/test/mock/mock_generator.go index 6beb1012a1..033b866aa1 100644 --- a/pkg/flink/test/mock/mock_generator.go +++ b/pkg/flink/test/mock/mock_generator.go @@ -1,17 +1,18 @@ package mock -// Generating mocks using reflect mode: https://github.com/golang/mock#reflect-mode +// Generating mocks using reflect mode: https://github.com/uber-go/mock // controllers -//go:generate mockgen -destination application_controller_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types ApplicationControllerInterface -//go:generate mockgen -destination input_controller_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types InputControllerInterface -//go:generate mockgen -destination result_fetcher_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types ResultFetcherInterface -//go:generate mockgen -destination statement_controller_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types StatementControllerInterface -//go:generate mockgen -destination output_controller_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types OutputControllerInterface -//go:generate mockgen -destination store_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types StoreInterface -//go:generate mockgen -destination reverse_i_search_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/internal/reverseisearch ReverseISearch -//go:generate mockgen -destination gateway_client_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/ccloudv2 GatewayClientInterface -//go:generate mockgen -destination table_view_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/components TableViewInterface -//go:generate mockgen -destination prompt_mock.go -package=mock github.com/confluentinc/go-prompt IPrompt -//go:generate mockgen -destination console_parser_mock.go -package=mock github.com/confluentinc/go-prompt ConsoleParser -//go:generate mockgen -destination json_rpc2_conn.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types JSONRpcConn +//go:generate go run go.uber.org/mock/mockgen -destination application_controller_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types ApplicationControllerInterface +//go:generate go run go.uber.org/mock/mockgen -destination input_controller_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types InputControllerInterface +//go:generate go run go.uber.org/mock/mockgen -destination result_fetcher_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types ResultFetcherInterface +//go:generate go run go.uber.org/mock/mockgen -destination statement_controller_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types StatementControllerInterface +//go:generate go run go.uber.org/mock/mockgen -destination output_controller_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types OutputControllerInterface +//go:generate go run go.uber.org/mock/mockgen -destination store_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types StoreInterface +//go:generate go run go.uber.org/mock/mockgen -destination reverse_i_search_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/internal/reverseisearch ReverseISearch +//go:generate go run go.uber.org/mock/mockgen -destination gateway_client_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/ccloudv2 GatewayClientInterface +//go:generate go run go.uber.org/mock/mockgen -destination table_view_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/components TableViewInterface +//go:generate go run go.uber.org/mock/mockgen -destination prompt_mock.go -package=mock github.com/confluentinc/go-prompt IPrompt +//go:generate go run go.uber.org/mock/mockgen -destination console_parser_mock.go -package=mock github.com/confluentinc/go-prompt ConsoleParser +//go:generate go run go.uber.org/mock/mockgen -destination json_rpc2_conn.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types JSONRpcConn +//go:generate go run go.uber.org/mock/mockgen -destination cmf_client_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink CmfClientInterface diff --git a/pkg/flink/test/mock/output_controller_mock.go b/pkg/flink/test/mock/output_controller_mock.go index 5c3eb1700d..530cea2006 100644 --- a/pkg/flink/test/mock/output_controller_mock.go +++ b/pkg/flink/test/mock/output_controller_mock.go @@ -19,6 +19,7 @@ import ( type MockOutputControllerInterface struct { ctrl *gomock.Controller recorder *MockOutputControllerInterfaceMockRecorder + isgomock struct{} } // MockOutputControllerInterfaceMockRecorder is the mock recorder for MockOutputControllerInterface. diff --git a/pkg/flink/test/mock/prompt_mock.go b/pkg/flink/test/mock/prompt_mock.go index 07e5ab5c2d..bed81c5b8c 100644 --- a/pkg/flink/test/mock/prompt_mock.go +++ b/pkg/flink/test/mock/prompt_mock.go @@ -21,6 +21,7 @@ import ( type MockIPrompt struct { ctrl *gomock.Controller recorder *MockIPromptMockRecorder + isgomock struct{} } // MockIPromptMockRecorder is the mock recorder for MockIPrompt. @@ -205,15 +206,15 @@ func (mr *MockIPromptMockRecorder) SetConsoleParser(arg0 any) *gomock.Call { } // SetDiagnostics mocks base method. -func (m *MockIPrompt) SetDiagnostics(arg0 []lsp.Diagnostic) { +func (m *MockIPrompt) SetDiagnostics(diagnostics []lsp.Diagnostic) { m.ctrl.T.Helper() - m.ctrl.Call(m, "SetDiagnostics", arg0) + m.ctrl.Call(m, "SetDiagnostics", diagnostics) } // SetDiagnostics indicates an expected call of SetDiagnostics. -func (mr *MockIPromptMockRecorder) SetDiagnostics(arg0 any) *gomock.Call { +func (mr *MockIPromptMockRecorder) SetDiagnostics(diagnostics any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetDiagnostics", reflect.TypeOf((*MockIPrompt)(nil).SetDiagnostics), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetDiagnostics", reflect.TypeOf((*MockIPrompt)(nil).SetDiagnostics), diagnostics) } // SetExitChecker mocks base method. diff --git a/pkg/flink/test/mock/result_fetcher_mock.go b/pkg/flink/test/mock/result_fetcher_mock.go index a54f3197fb..24588a2269 100644 --- a/pkg/flink/test/mock/result_fetcher_mock.go +++ b/pkg/flink/test/mock/result_fetcher_mock.go @@ -21,6 +21,7 @@ import ( type MockResultFetcherInterface struct { ctrl *gomock.Controller recorder *MockResultFetcherInterfaceMockRecorder + isgomock struct{} } // MockResultFetcherInterfaceMockRecorder is the mock recorder for MockResultFetcherInterface. @@ -109,15 +110,15 @@ func (mr *MockResultFetcherInterfaceMockRecorder) GetStatement() *gomock.Call { } // Init mocks base method. -func (m *MockResultFetcherInterface) Init(arg0 types.ProcessedStatement) { +func (m *MockResultFetcherInterface) Init(statement types.ProcessedStatement) { m.ctrl.T.Helper() - m.ctrl.Call(m, "Init", arg0) + m.ctrl.Call(m, "Init", statement) } // Init indicates an expected call of Init. -func (mr *MockResultFetcherInterfaceMockRecorder) Init(arg0 any) *gomock.Call { +func (mr *MockResultFetcherInterfaceMockRecorder) Init(statement any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Init", reflect.TypeOf((*MockResultFetcherInterface)(nil).Init), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Init", reflect.TypeOf((*MockResultFetcherInterface)(nil).Init), statement) } // IsRefreshRunning mocks base method. diff --git a/pkg/flink/test/mock/reverse_i_search_mock.go b/pkg/flink/test/mock/reverse_i_search_mock.go index 616235ddab..4ccfe0cd22 100644 --- a/pkg/flink/test/mock/reverse_i_search_mock.go +++ b/pkg/flink/test/mock/reverse_i_search_mock.go @@ -19,6 +19,7 @@ import ( type MockReverseISearch struct { ctrl *gomock.Controller recorder *MockReverseISearchMockRecorder + isgomock struct{} } // MockReverseISearchMockRecorder is the mock recorder for MockReverseISearch. @@ -39,15 +40,15 @@ func (m *MockReverseISearch) EXPECT() *MockReverseISearchMockRecorder { } // ReverseISearch mocks base method. -func (m *MockReverseISearch) ReverseISearch(arg0 []string, arg1 string) string { +func (m *MockReverseISearch) ReverseISearch(history []string, initialText string) string { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ReverseISearch", arg0, arg1) + ret := m.ctrl.Call(m, "ReverseISearch", history, initialText) ret0, _ := ret[0].(string) return ret0 } // ReverseISearch indicates an expected call of ReverseISearch. -func (mr *MockReverseISearchMockRecorder) ReverseISearch(arg0, arg1 any) *gomock.Call { +func (mr *MockReverseISearchMockRecorder) ReverseISearch(history, initialText any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReverseISearch", reflect.TypeOf((*MockReverseISearch)(nil).ReverseISearch), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReverseISearch", reflect.TypeOf((*MockReverseISearch)(nil).ReverseISearch), history, initialText) } diff --git a/pkg/flink/test/mock/statement_controller_mock.go b/pkg/flink/test/mock/statement_controller_mock.go index dc0ed0ab88..94daa39558 100644 --- a/pkg/flink/test/mock/statement_controller_mock.go +++ b/pkg/flink/test/mock/statement_controller_mock.go @@ -20,6 +20,7 @@ import ( type MockStatementControllerInterface struct { ctrl *gomock.Controller recorder *MockStatementControllerInterfaceMockRecorder + isgomock struct{} } // MockStatementControllerInterfaceMockRecorder is the mock recorder for MockStatementControllerInterface. @@ -52,16 +53,16 @@ func (mr *MockStatementControllerInterfaceMockRecorder) CleanupStatement() *gomo } // ExecuteStatement mocks base method. -func (m *MockStatementControllerInterface) ExecuteStatement(arg0 string) (*types.ProcessedStatement, *types.StatementError) { +func (m *MockStatementControllerInterface) ExecuteStatement(statementToExecute string) (*types.ProcessedStatement, *types.StatementError) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ExecuteStatement", arg0) + ret := m.ctrl.Call(m, "ExecuteStatement", statementToExecute) ret0, _ := ret[0].(*types.ProcessedStatement) ret1, _ := ret[1].(*types.StatementError) return ret0, ret1 } // ExecuteStatement indicates an expected call of ExecuteStatement. -func (mr *MockStatementControllerInterfaceMockRecorder) ExecuteStatement(arg0 any) *gomock.Call { +func (mr *MockStatementControllerInterfaceMockRecorder) ExecuteStatement(statementToExecute any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExecuteStatement", reflect.TypeOf((*MockStatementControllerInterface)(nil).ExecuteStatement), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExecuteStatement", reflect.TypeOf((*MockStatementControllerInterface)(nil).ExecuteStatement), statementToExecute) } diff --git a/pkg/flink/test/mock/store_mock.go b/pkg/flink/test/mock/store_mock.go index 27814ec027..294a18ee2a 100644 --- a/pkg/flink/test/mock/store_mock.go +++ b/pkg/flink/test/mock/store_mock.go @@ -3,7 +3,7 @@ // // Generated by this command: // -// mockgen -destination pkg/flink/test/mock/store_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types StoreInterface +// mockgen -destination store_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types StoreInterface // // Package mock is a generated GoMock package. diff --git a/pkg/flink/test/mock/table_view_mock.go b/pkg/flink/test/mock/table_view_mock.go index 4d7106a756..3e5efd8221 100644 --- a/pkg/flink/test/mock/table_view_mock.go +++ b/pkg/flink/test/mock/table_view_mock.go @@ -22,6 +22,7 @@ import ( type MockTableViewInterface struct { ctrl *gomock.Controller recorder *MockTableViewInterfaceMockRecorder + isgomock struct{} } // MockTableViewInterfaceMockRecorder is the mock recorder for MockTableViewInterface. @@ -120,13 +121,13 @@ func (mr *MockTableViewInterfaceMockRecorder) JumpUp() *gomock.Call { } // RenderTable mocks base method. -func (m *MockTableViewInterface) RenderTable(arg0 string, arg1 *types.MaterializedStatementResults, arg2 *time.Time, arg3 types.RefreshState) { +func (m *MockTableViewInterface) RenderTable(tableTitle string, statementResults *types.MaterializedStatementResults, lastRefreshTimestamp *time.Time, refreshState types.RefreshState) { m.ctrl.T.Helper() - m.ctrl.Call(m, "RenderTable", arg0, arg1, arg2, arg3) + m.ctrl.Call(m, "RenderTable", tableTitle, statementResults, lastRefreshTimestamp, refreshState) } // RenderTable indicates an expected call of RenderTable. -func (mr *MockTableViewInterfaceMockRecorder) RenderTable(arg0, arg1, arg2, arg3 any) *gomock.Call { +func (mr *MockTableViewInterfaceMockRecorder) RenderTable(tableTitle, statementResults, lastRefreshTimestamp, refreshState any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RenderTable", reflect.TypeOf((*MockTableViewInterface)(nil).RenderTable), arg0, arg1, arg2, arg3) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RenderTable", reflect.TypeOf((*MockTableViewInterface)(nil).RenderTable), tableTitle, statementResults, lastRefreshTimestamp, refreshState) } diff --git a/pkg/form/field_test.go b/pkg/form/field_test.go index 12ee3822cd..6b8ec945c3 100644 --- a/pkg/form/field_test.go +++ b/pkg/form/field_test.go @@ -5,6 +5,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.uber.org/mock/gomock" "github.com/confluentinc/cli/v4/pkg/mock" ) @@ -12,11 +13,9 @@ import ( func TestRead(t *testing.T) { var field Field - prompt := &mock.Prompt{ - ReadLineFunc: func() (string, error) { - return "user", nil - }, - } + ctrl := gomock.NewController(t) + prompt := mock.NewMockPrompt(ctrl) + prompt.EXPECT().ReadLine().Return("user", nil).AnyTimes() username, _ := field.read(prompt) require.Equal(t, "user", username) @@ -25,11 +24,9 @@ func TestRead(t *testing.T) { func TestRead_Password(t *testing.T) { field := Field{IsHidden: true} - prompt := &mock.Prompt{ - ReadLineMaskedFunc: func() (string, error) { - return "pass", nil - }, - } + ctrl := gomock.NewController(t) + prompt := mock.NewMockPrompt(ctrl) + prompt.EXPECT().ReadLineMasked().Return("pass", nil).AnyTimes() password, _ := field.read(prompt) require.Equal(t, "pass", password) diff --git a/pkg/form/form_test.go b/pkg/form/form_test.go index 1cbe6638e2..94bb051b09 100644 --- a/pkg/form/form_test.go +++ b/pkg/form/form_test.go @@ -5,6 +5,7 @@ import ( "testing" "github.com/stretchr/testify/require" + "go.uber.org/mock/gomock" "github.com/confluentinc/cli/v4/pkg/mock" ) @@ -15,14 +16,10 @@ func TestPrompt(t *testing.T) { Field{ID: "password", Prompt: "Password", IsHidden: true}, ) - prompt := &mock.Prompt{ - ReadLineFunc: func() (string, error) { - return "user", nil - }, - ReadLineMaskedFunc: func() (string, error) { - return "pass", nil - }, - } + ctrl := gomock.NewController(t) + prompt := mock.NewMockPrompt(ctrl) + prompt.EXPECT().ReadLine().Return("user", nil).AnyTimes() + prompt.EXPECT().ReadLineMasked().Return("pass", nil).AnyTimes() err := f.Prompt(prompt) require.NoError(t, err) diff --git a/pkg/form/prompt.go b/pkg/form/prompt.go index d530c4dff5..bc0c0a6d87 100644 --- a/pkg/form/prompt.go +++ b/pkg/form/prompt.go @@ -1,4 +1,4 @@ -//go:generate go run github.com/travisjeffery/mocker/cmd/mocker --prefix "" --dst ../mock/prompt.go --pkg mock --selfpkg github.com/confluentinc/cli/v4 prompt.go Prompt +//go:generate go run go.uber.org/mock/mockgen -typed -destination=../mock/prompt.go -package=mock github.com/confluentinc/cli/v4/pkg/form Prompt package form diff --git a/pkg/io/io.go b/pkg/io/io.go index bb40d38e24..0c8737ef60 100644 --- a/pkg/io/io.go +++ b/pkg/io/io.go @@ -1,4 +1,4 @@ -//go:generate go run github.com/travisjeffery/mocker/cmd/mocker --prefix "" --dst ../mock/filesystem.go --pkg mock io.go FileSystem +//go:generate go run go.uber.org/mock/mockgen -typed -destination=../mock/filesystem.go -package=mock github.com/confluentinc/cli/v4/pkg/io FileSystem package io diff --git a/pkg/local/confluent_current.go b/pkg/local/confluent_current.go index 0971ead114..047a0df83f 100644 --- a/pkg/local/confluent_current.go +++ b/pkg/local/confluent_current.go @@ -1,4 +1,4 @@ -//go:generate go run github.com/travisjeffery/mocker/cmd/mocker --dst ../../mock/confluent_current.go --pkg mock --selfpkg github.com/confluentinc/cli/v4 confluent_current.go ConfluentCurrent +//go:generate go run go.uber.org/mock/mockgen -typed -destination=../../mock/confluent_current.go -package=mock github.com/confluentinc/cli/v4/pkg/local ConfluentCurrent package local diff --git a/pkg/local/confluent_home.go b/pkg/local/confluent_home.go index 5f66fa7cb6..401e93e04f 100644 --- a/pkg/local/confluent_home.go +++ b/pkg/local/confluent_home.go @@ -1,4 +1,4 @@ -//go:generate go run github.com/travisjeffery/mocker/cmd/mocker --dst ../../mock/confluent_home.go --pkg mock --selfpkg github.com/confluentinc/cli/v4 confluent_home.go ConfluentHome +//go:generate go run go.uber.org/mock/mockgen -typed -destination=../../mock/confluent_home.go -package=mock github.com/confluentinc/cli/v4/pkg/local ConfluentHome package local diff --git a/pkg/mock/filesystem.go b/pkg/mock/filesystem.go index 186c513e48..753bef1f7f 100644 --- a/pkg/mock/filesystem.go +++ b/pkg/mock/filesystem.go @@ -1,706 +1,583 @@ -// Code generated by mocker. DO NOT EDIT. -// github.com/travisjeffery/mocker -// Source: io.go - +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/confluentinc/cli/v4/pkg/io (interfaces: FileSystem) +// +// Generated by this command: +// +// mockgen -typed -destination=../mock/filesystem.go -package=mock github.com/confluentinc/cli/v4/pkg/io FileSystem +// + +// Package mock is a generated GoMock package. package mock import ( - io "io" + io0 "io" os "os" - sync "sync" + reflect "reflect" time "time" - github_com_confluentinc_cli_internal_pkg_io "github.com/confluentinc/cli/v4/pkg/io" + io "github.com/confluentinc/cli/v4/pkg/io" + gomock "go.uber.org/mock/gomock" ) -// FileSystem is a mock of FileSystem interface -type FileSystem struct { - lockOpen sync.Mutex - OpenFunc func(name string) (github_com_confluentinc_cli_internal_pkg_io.File, error) - - lockStat sync.Mutex - StatFunc func(name string) (os.FileInfo, error) - - lockCreate sync.Mutex - CreateFunc func(name string) (github_com_confluentinc_cli_internal_pkg_io.File, error) - - lockChtimes sync.Mutex - ChtimesFunc func(name string, atime, mtime time.Time) error - - lockChmod sync.Mutex - ChmodFunc func(name string, mode os.FileMode) error - - lockRemove sync.Mutex - RemoveFunc func(name string) error - - lockRemoveAll sync.Mutex - RemoveAllFunc func(path string) error - - lockReadDir sync.Mutex - ReadDirFunc func(dirname string) ([]os.DirEntry, error) - - lockMkdirTemp sync.Mutex - MkdirTempFunc func(dir, prefix string) (string, error) - - lockCopy sync.Mutex - CopyFunc func(dst io.Writer, src io.Reader) (int64, error) - - lockMove sync.Mutex - MoveFunc func(src, dst string) error - - lockNewBufferedReader sync.Mutex - NewBufferedReaderFunc func(rd io.Reader) github_com_confluentinc_cli_internal_pkg_io.Reader - - lockIsTerminal sync.Mutex - IsTerminalFunc func(fd uintptr) bool - - lockGlob sync.Mutex - GlobFunc func(pattern string) ([]string, error) - - calls struct { - Open []struct { - Name string - } - Stat []struct { - Name string - } - Create []struct { - Name string - } - Chtimes []struct { - Name string - Atime time.Time - Mtime time.Time - } - Chmod []struct { - Name string - Mode os.FileMode - } - Remove []struct { - Name string - } - RemoveAll []struct { - Path string - } - ReadDir []struct { - Dirname string - } - MkdirTemp []struct { - Dir string - Prefix string - } - Copy []struct { - Dst io.Writer - Src io.Reader - } - Move []struct { - Src string - Dst string - } - NewBufferedReader []struct { - Rd io.Reader - } - IsTerminal []struct { - Fd uintptr - } - Glob []struct { - Pattern string - } - } -} - -// Open mocks base method by wrapping the associated func. -func (m *FileSystem) Open(name string) (github_com_confluentinc_cli_internal_pkg_io.File, error) { - m.lockOpen.Lock() - defer m.lockOpen.Unlock() - - if m.OpenFunc == nil { - panic("mocker: FileSystem.OpenFunc is nil but FileSystem.Open was called.") - } - - call := struct { - Name string - }{ - Name: name, - } - - m.calls.Open = append(m.calls.Open, call) - - return m.OpenFunc(name) -} - -// OpenCalled returns true if Open was called at least once. -func (m *FileSystem) OpenCalled() bool { - m.lockOpen.Lock() - defer m.lockOpen.Unlock() - - return len(m.calls.Open) > 0 -} - -// OpenCalls returns the calls made to Open. -func (m *FileSystem) OpenCalls() []struct { - Name string -} { - m.lockOpen.Lock() - defer m.lockOpen.Unlock() - - return m.calls.Open -} - -// Stat mocks base method by wrapping the associated func. -func (m *FileSystem) Stat(name string) (os.FileInfo, error) { - m.lockStat.Lock() - defer m.lockStat.Unlock() - - if m.StatFunc == nil { - panic("mocker: FileSystem.StatFunc is nil but FileSystem.Stat was called.") - } - - call := struct { - Name string - }{ - Name: name, - } - - m.calls.Stat = append(m.calls.Stat, call) - - return m.StatFunc(name) -} - -// StatCalled returns true if Stat was called at least once. -func (m *FileSystem) StatCalled() bool { - m.lockStat.Lock() - defer m.lockStat.Unlock() - - return len(m.calls.Stat) > 0 +// MockFileSystem is a mock of FileSystem interface. +type MockFileSystem struct { + ctrl *gomock.Controller + recorder *MockFileSystemMockRecorder + isgomock struct{} } -// StatCalls returns the calls made to Stat. -func (m *FileSystem) StatCalls() []struct { - Name string -} { - m.lockStat.Lock() - defer m.lockStat.Unlock() - - return m.calls.Stat +// MockFileSystemMockRecorder is the mock recorder for MockFileSystem. +type MockFileSystemMockRecorder struct { + mock *MockFileSystem } -// Create mocks base method by wrapping the associated func. -func (m *FileSystem) Create(name string) (github_com_confluentinc_cli_internal_pkg_io.File, error) { - m.lockCreate.Lock() - defer m.lockCreate.Unlock() - - if m.CreateFunc == nil { - panic("mocker: FileSystem.CreateFunc is nil but FileSystem.Create was called.") - } - - call := struct { - Name string - }{ - Name: name, - } - - m.calls.Create = append(m.calls.Create, call) - - return m.CreateFunc(name) +// NewMockFileSystem creates a new mock instance. +func NewMockFileSystem(ctrl *gomock.Controller) *MockFileSystem { + mock := &MockFileSystem{ctrl: ctrl} + mock.recorder = &MockFileSystemMockRecorder{mock} + return mock } -// CreateCalled returns true if Create was called at least once. -func (m *FileSystem) CreateCalled() bool { - m.lockCreate.Lock() - defer m.lockCreate.Unlock() - - return len(m.calls.Create) > 0 +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockFileSystem) EXPECT() *MockFileSystemMockRecorder { + return m.recorder } -// CreateCalls returns the calls made to Create. -func (m *FileSystem) CreateCalls() []struct { - Name string -} { - m.lockCreate.Lock() - defer m.lockCreate.Unlock() - - return m.calls.Create +// Chmod mocks base method. +func (m *MockFileSystem) Chmod(name string, mode os.FileMode) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Chmod", name, mode) + ret0, _ := ret[0].(error) + return ret0 } -// Chtimes mocks base method by wrapping the associated func. -func (m *FileSystem) Chtimes(name string, atime, mtime time.Time) error { - m.lockChtimes.Lock() - defer m.lockChtimes.Unlock() - - if m.ChtimesFunc == nil { - panic("mocker: FileSystem.ChtimesFunc is nil but FileSystem.Chtimes was called.") - } - - call := struct { - Name string - Atime time.Time - Mtime time.Time - }{ - Name: name, - Atime: atime, - Mtime: mtime, - } - - m.calls.Chtimes = append(m.calls.Chtimes, call) - - return m.ChtimesFunc(name, atime, mtime) +// Chmod indicates an expected call of Chmod. +func (mr *MockFileSystemMockRecorder) Chmod(name, mode any) *MockFileSystemChmodCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Chmod", reflect.TypeOf((*MockFileSystem)(nil).Chmod), name, mode) + return &MockFileSystemChmodCall{Call: call} } -// ChtimesCalled returns true if Chtimes was called at least once. -func (m *FileSystem) ChtimesCalled() bool { - m.lockChtimes.Lock() - defer m.lockChtimes.Unlock() - - return len(m.calls.Chtimes) > 0 +// MockFileSystemChmodCall wrap *gomock.Call +type MockFileSystemChmodCall struct { + *gomock.Call } -// ChtimesCalls returns the calls made to Chtimes. -func (m *FileSystem) ChtimesCalls() []struct { - Name string - Atime time.Time - Mtime time.Time -} { - m.lockChtimes.Lock() - defer m.lockChtimes.Unlock() - - return m.calls.Chtimes +// Return rewrite *gomock.Call.Return +func (c *MockFileSystemChmodCall) Return(arg0 error) *MockFileSystemChmodCall { + c.Call = c.Call.Return(arg0) + return c } -// Chmod mocks base method by wrapping the associated func. -func (m *FileSystem) Chmod(name string, mode os.FileMode) error { - m.lockChmod.Lock() - defer m.lockChmod.Unlock() +// Do rewrite *gomock.Call.Do +func (c *MockFileSystemChmodCall) Do(f func(string, os.FileMode) error) *MockFileSystemChmodCall { + c.Call = c.Call.Do(f) + return c +} - if m.ChmodFunc == nil { - panic("mocker: FileSystem.ChmodFunc is nil but FileSystem.Chmod was called.") - } +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFileSystemChmodCall) DoAndReturn(f func(string, os.FileMode) error) *MockFileSystemChmodCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - call := struct { - Name string - Mode os.FileMode - }{ - Name: name, - Mode: mode, - } +// Chtimes mocks base method. +func (m *MockFileSystem) Chtimes(name string, atime, mtime time.Time) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Chtimes", name, atime, mtime) + ret0, _ := ret[0].(error) + return ret0 +} - m.calls.Chmod = append(m.calls.Chmod, call) +// Chtimes indicates an expected call of Chtimes. +func (mr *MockFileSystemMockRecorder) Chtimes(name, atime, mtime any) *MockFileSystemChtimesCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Chtimes", reflect.TypeOf((*MockFileSystem)(nil).Chtimes), name, atime, mtime) + return &MockFileSystemChtimesCall{Call: call} +} - return m.ChmodFunc(name, mode) +// MockFileSystemChtimesCall wrap *gomock.Call +type MockFileSystemChtimesCall struct { + *gomock.Call } -// ChmodCalled returns true if Chmod was called at least once. -func (m *FileSystem) ChmodCalled() bool { - m.lockChmod.Lock() - defer m.lockChmod.Unlock() +// Return rewrite *gomock.Call.Return +func (c *MockFileSystemChtimesCall) Return(arg0 error) *MockFileSystemChtimesCall { + c.Call = c.Call.Return(arg0) + return c +} - return len(m.calls.Chmod) > 0 +// Do rewrite *gomock.Call.Do +func (c *MockFileSystemChtimesCall) Do(f func(string, time.Time, time.Time) error) *MockFileSystemChtimesCall { + c.Call = c.Call.Do(f) + return c } -// ChmodCalls returns the calls made to Chmod. -func (m *FileSystem) ChmodCalls() []struct { - Name string - Mode os.FileMode -} { - m.lockChmod.Lock() - defer m.lockChmod.Unlock() +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFileSystemChtimesCall) DoAndReturn(f func(string, time.Time, time.Time) error) *MockFileSystemChtimesCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - return m.calls.Chmod +// Copy mocks base method. +func (m *MockFileSystem) Copy(dst io0.Writer, src io0.Reader) (int64, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Copy", dst, src) + ret0, _ := ret[0].(int64) + ret1, _ := ret[1].(error) + return ret0, ret1 } -// Remove mocks base method by wrapping the associated func. -func (m *FileSystem) Remove(name string) error { - m.lockRemove.Lock() - defer m.lockRemove.Unlock() +// Copy indicates an expected call of Copy. +func (mr *MockFileSystemMockRecorder) Copy(dst, src any) *MockFileSystemCopyCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Copy", reflect.TypeOf((*MockFileSystem)(nil).Copy), dst, src) + return &MockFileSystemCopyCall{Call: call} +} - if m.RemoveFunc == nil { - panic("mocker: FileSystem.RemoveFunc is nil but FileSystem.Remove was called.") - } +// MockFileSystemCopyCall wrap *gomock.Call +type MockFileSystemCopyCall struct { + *gomock.Call +} - call := struct { - Name string - }{ - Name: name, - } +// Return rewrite *gomock.Call.Return +func (c *MockFileSystemCopyCall) Return(arg0 int64, arg1 error) *MockFileSystemCopyCall { + c.Call = c.Call.Return(arg0, arg1) + return c +} - m.calls.Remove = append(m.calls.Remove, call) +// Do rewrite *gomock.Call.Do +func (c *MockFileSystemCopyCall) Do(f func(io0.Writer, io0.Reader) (int64, error)) *MockFileSystemCopyCall { + c.Call = c.Call.Do(f) + return c +} - return m.RemoveFunc(name) +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFileSystemCopyCall) DoAndReturn(f func(io0.Writer, io0.Reader) (int64, error)) *MockFileSystemCopyCall { + c.Call = c.Call.DoAndReturn(f) + return c } -// RemoveCalled returns true if Remove was called at least once. -func (m *FileSystem) RemoveCalled() bool { - m.lockRemove.Lock() - defer m.lockRemove.Unlock() +// Create mocks base method. +func (m *MockFileSystem) Create(name string) (io.File, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Create", name) + ret0, _ := ret[0].(io.File) + ret1, _ := ret[1].(error) + return ret0, ret1 +} - return len(m.calls.Remove) > 0 +// Create indicates an expected call of Create. +func (mr *MockFileSystemMockRecorder) Create(name any) *MockFileSystemCreateCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockFileSystem)(nil).Create), name) + return &MockFileSystemCreateCall{Call: call} } -// RemoveCalls returns the calls made to Remove. -func (m *FileSystem) RemoveCalls() []struct { - Name string -} { - m.lockRemove.Lock() - defer m.lockRemove.Unlock() +// MockFileSystemCreateCall wrap *gomock.Call +type MockFileSystemCreateCall struct { + *gomock.Call +} - return m.calls.Remove +// Return rewrite *gomock.Call.Return +func (c *MockFileSystemCreateCall) Return(arg0 io.File, arg1 error) *MockFileSystemCreateCall { + c.Call = c.Call.Return(arg0, arg1) + return c } -// RemoveAll mocks base method by wrapping the associated func. -func (m *FileSystem) RemoveAll(path string) error { - m.lockRemoveAll.Lock() - defer m.lockRemoveAll.Unlock() +// Do rewrite *gomock.Call.Do +func (c *MockFileSystemCreateCall) Do(f func(string) (io.File, error)) *MockFileSystemCreateCall { + c.Call = c.Call.Do(f) + return c +} - if m.RemoveAllFunc == nil { - panic("mocker: FileSystem.RemoveAllFunc is nil but FileSystem.RemoveAll was called.") - } +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFileSystemCreateCall) DoAndReturn(f func(string) (io.File, error)) *MockFileSystemCreateCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - call := struct { - Path string - }{ - Path: path, - } +// Glob mocks base method. +func (m *MockFileSystem) Glob(pattern string) ([]string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Glob", pattern) + ret0, _ := ret[0].([]string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} - m.calls.RemoveAll = append(m.calls.RemoveAll, call) +// Glob indicates an expected call of Glob. +func (mr *MockFileSystemMockRecorder) Glob(pattern any) *MockFileSystemGlobCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Glob", reflect.TypeOf((*MockFileSystem)(nil).Glob), pattern) + return &MockFileSystemGlobCall{Call: call} +} - return m.RemoveAllFunc(path) +// MockFileSystemGlobCall wrap *gomock.Call +type MockFileSystemGlobCall struct { + *gomock.Call } -// RemoveAllCalled returns true if RemoveAll was called at least once. -func (m *FileSystem) RemoveAllCalled() bool { - m.lockRemoveAll.Lock() - defer m.lockRemoveAll.Unlock() +// Return rewrite *gomock.Call.Return +func (c *MockFileSystemGlobCall) Return(arg0 []string, arg1 error) *MockFileSystemGlobCall { + c.Call = c.Call.Return(arg0, arg1) + return c +} - return len(m.calls.RemoveAll) > 0 +// Do rewrite *gomock.Call.Do +func (c *MockFileSystemGlobCall) Do(f func(string) ([]string, error)) *MockFileSystemGlobCall { + c.Call = c.Call.Do(f) + return c } -// RemoveAllCalls returns the calls made to RemoveAll. -func (m *FileSystem) RemoveAllCalls() []struct { - Path string -} { - m.lockRemoveAll.Lock() - defer m.lockRemoveAll.Unlock() +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFileSystemGlobCall) DoAndReturn(f func(string) ([]string, error)) *MockFileSystemGlobCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - return m.calls.RemoveAll +// IsTerminal mocks base method. +func (m *MockFileSystem) IsTerminal(fd uintptr) bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsTerminal", fd) + ret0, _ := ret[0].(bool) + return ret0 } -// ReadDir mocks base method by wrapping the associated func. -func (m *FileSystem) ReadDir(dirname string) ([]os.DirEntry, error) { - m.lockReadDir.Lock() - defer m.lockReadDir.Unlock() +// IsTerminal indicates an expected call of IsTerminal. +func (mr *MockFileSystemMockRecorder) IsTerminal(fd any) *MockFileSystemIsTerminalCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsTerminal", reflect.TypeOf((*MockFileSystem)(nil).IsTerminal), fd) + return &MockFileSystemIsTerminalCall{Call: call} +} - if m.ReadDirFunc == nil { - panic("mocker: FileSystem.ReadDirFunc is nil but FileSystem.ReadDir was called.") - } +// MockFileSystemIsTerminalCall wrap *gomock.Call +type MockFileSystemIsTerminalCall struct { + *gomock.Call +} - call := struct { - Dirname string - }{ - Dirname: dirname, - } +// Return rewrite *gomock.Call.Return +func (c *MockFileSystemIsTerminalCall) Return(arg0 bool) *MockFileSystemIsTerminalCall { + c.Call = c.Call.Return(arg0) + return c +} - m.calls.ReadDir = append(m.calls.ReadDir, call) +// Do rewrite *gomock.Call.Do +func (c *MockFileSystemIsTerminalCall) Do(f func(uintptr) bool) *MockFileSystemIsTerminalCall { + c.Call = c.Call.Do(f) + return c +} - return m.ReadDirFunc(dirname) +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFileSystemIsTerminalCall) DoAndReturn(f func(uintptr) bool) *MockFileSystemIsTerminalCall { + c.Call = c.Call.DoAndReturn(f) + return c } -// ReadDirCalled returns true if ReadDir was called at least once. -func (m *FileSystem) ReadDirCalled() bool { - m.lockReadDir.Lock() - defer m.lockReadDir.Unlock() +// MkdirTemp mocks base method. +func (m *MockFileSystem) MkdirTemp(dir, prefix string) (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "MkdirTemp", dir, prefix) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} - return len(m.calls.ReadDir) > 0 +// MkdirTemp indicates an expected call of MkdirTemp. +func (mr *MockFileSystemMockRecorder) MkdirTemp(dir, prefix any) *MockFileSystemMkdirTempCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MkdirTemp", reflect.TypeOf((*MockFileSystem)(nil).MkdirTemp), dir, prefix) + return &MockFileSystemMkdirTempCall{Call: call} } -// ReadDirCalls returns the calls made to ReadDir. -func (m *FileSystem) ReadDirCalls() []struct { - Dirname string -} { - m.lockReadDir.Lock() - defer m.lockReadDir.Unlock() +// MockFileSystemMkdirTempCall wrap *gomock.Call +type MockFileSystemMkdirTempCall struct { + *gomock.Call +} - return m.calls.ReadDir +// Return rewrite *gomock.Call.Return +func (c *MockFileSystemMkdirTempCall) Return(arg0 string, arg1 error) *MockFileSystemMkdirTempCall { + c.Call = c.Call.Return(arg0, arg1) + return c } -// MkdirTemp mocks base method by wrapping the associated func. -func (m *FileSystem) MkdirTemp(dir, prefix string) (string, error) { - m.lockMkdirTemp.Lock() - defer m.lockMkdirTemp.Unlock() +// Do rewrite *gomock.Call.Do +func (c *MockFileSystemMkdirTempCall) Do(f func(string, string) (string, error)) *MockFileSystemMkdirTempCall { + c.Call = c.Call.Do(f) + return c +} - if m.MkdirTempFunc == nil { - panic("mocker: FileSystem.MkdirTempFunc is nil but FileSystem.MkdirTemp was called.") - } +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFileSystemMkdirTempCall) DoAndReturn(f func(string, string) (string, error)) *MockFileSystemMkdirTempCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - call := struct { - Dir string - Prefix string - }{ - Dir: dir, - Prefix: prefix, - } +// Move mocks base method. +func (m *MockFileSystem) Move(src, dst string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Move", src, dst) + ret0, _ := ret[0].(error) + return ret0 +} - m.calls.MkdirTemp = append(m.calls.MkdirTemp, call) +// Move indicates an expected call of Move. +func (mr *MockFileSystemMockRecorder) Move(src, dst any) *MockFileSystemMoveCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Move", reflect.TypeOf((*MockFileSystem)(nil).Move), src, dst) + return &MockFileSystemMoveCall{Call: call} +} - return m.MkdirTempFunc(dir, prefix) +// MockFileSystemMoveCall wrap *gomock.Call +type MockFileSystemMoveCall struct { + *gomock.Call } -// MkdirTempCalled returns true if MkdirTemp was called at least once. -func (m *FileSystem) MkdirTempCalled() bool { - m.lockMkdirTemp.Lock() - defer m.lockMkdirTemp.Unlock() +// Return rewrite *gomock.Call.Return +func (c *MockFileSystemMoveCall) Return(arg0 error) *MockFileSystemMoveCall { + c.Call = c.Call.Return(arg0) + return c +} - return len(m.calls.MkdirTemp) > 0 +// Do rewrite *gomock.Call.Do +func (c *MockFileSystemMoveCall) Do(f func(string, string) error) *MockFileSystemMoveCall { + c.Call = c.Call.Do(f) + return c } -// MkdirTempCalls returns the calls made to MkdirTemp. -func (m *FileSystem) MkdirTempCalls() []struct { - Dir string - Prefix string -} { - m.lockMkdirTemp.Lock() - defer m.lockMkdirTemp.Unlock() +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFileSystemMoveCall) DoAndReturn(f func(string, string) error) *MockFileSystemMoveCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - return m.calls.MkdirTemp +// NewBufferedReader mocks base method. +func (m *MockFileSystem) NewBufferedReader(rd io0.Reader) io.Reader { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "NewBufferedReader", rd) + ret0, _ := ret[0].(io.Reader) + return ret0 } -// Copy mocks base method by wrapping the associated func. -func (m *FileSystem) Copy(dst io.Writer, src io.Reader) (int64, error) { - m.lockCopy.Lock() - defer m.lockCopy.Unlock() +// NewBufferedReader indicates an expected call of NewBufferedReader. +func (mr *MockFileSystemMockRecorder) NewBufferedReader(rd any) *MockFileSystemNewBufferedReaderCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewBufferedReader", reflect.TypeOf((*MockFileSystem)(nil).NewBufferedReader), rd) + return &MockFileSystemNewBufferedReaderCall{Call: call} +} - if m.CopyFunc == nil { - panic("mocker: FileSystem.CopyFunc is nil but FileSystem.Copy was called.") - } +// MockFileSystemNewBufferedReaderCall wrap *gomock.Call +type MockFileSystemNewBufferedReaderCall struct { + *gomock.Call +} - call := struct { - Dst io.Writer - Src io.Reader - }{ - Dst: dst, - Src: src, - } +// Return rewrite *gomock.Call.Return +func (c *MockFileSystemNewBufferedReaderCall) Return(arg0 io.Reader) *MockFileSystemNewBufferedReaderCall { + c.Call = c.Call.Return(arg0) + return c +} - m.calls.Copy = append(m.calls.Copy, call) +// Do rewrite *gomock.Call.Do +func (c *MockFileSystemNewBufferedReaderCall) Do(f func(io0.Reader) io.Reader) *MockFileSystemNewBufferedReaderCall { + c.Call = c.Call.Do(f) + return c +} - return m.CopyFunc(dst, src) +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFileSystemNewBufferedReaderCall) DoAndReturn(f func(io0.Reader) io.Reader) *MockFileSystemNewBufferedReaderCall { + c.Call = c.Call.DoAndReturn(f) + return c } -// CopyCalled returns true if Copy was called at least once. -func (m *FileSystem) CopyCalled() bool { - m.lockCopy.Lock() - defer m.lockCopy.Unlock() +// Open mocks base method. +func (m *MockFileSystem) Open(name string) (io.File, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Open", name) + ret0, _ := ret[0].(io.File) + ret1, _ := ret[1].(error) + return ret0, ret1 +} - return len(m.calls.Copy) > 0 +// Open indicates an expected call of Open. +func (mr *MockFileSystemMockRecorder) Open(name any) *MockFileSystemOpenCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Open", reflect.TypeOf((*MockFileSystem)(nil).Open), name) + return &MockFileSystemOpenCall{Call: call} } -// CopyCalls returns the calls made to Copy. -func (m *FileSystem) CopyCalls() []struct { - Dst io.Writer - Src io.Reader -} { - m.lockCopy.Lock() - defer m.lockCopy.Unlock() +// MockFileSystemOpenCall wrap *gomock.Call +type MockFileSystemOpenCall struct { + *gomock.Call +} - return m.calls.Copy +// Return rewrite *gomock.Call.Return +func (c *MockFileSystemOpenCall) Return(arg0 io.File, arg1 error) *MockFileSystemOpenCall { + c.Call = c.Call.Return(arg0, arg1) + return c } -// Move mocks base method by wrapping the associated func. -func (m *FileSystem) Move(src, dst string) error { - m.lockMove.Lock() - defer m.lockMove.Unlock() +// Do rewrite *gomock.Call.Do +func (c *MockFileSystemOpenCall) Do(f func(string) (io.File, error)) *MockFileSystemOpenCall { + c.Call = c.Call.Do(f) + return c +} - if m.MoveFunc == nil { - panic("mocker: FileSystem.MoveFunc is nil but FileSystem.Move was called.") - } +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFileSystemOpenCall) DoAndReturn(f func(string) (io.File, error)) *MockFileSystemOpenCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - call := struct { - Src string - Dst string - }{ - Src: src, - Dst: dst, - } +// ReadDir mocks base method. +func (m *MockFileSystem) ReadDir(dirname string) ([]os.DirEntry, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReadDir", dirname) + ret0, _ := ret[0].([]os.DirEntry) + ret1, _ := ret[1].(error) + return ret0, ret1 +} - m.calls.Move = append(m.calls.Move, call) +// ReadDir indicates an expected call of ReadDir. +func (mr *MockFileSystemMockRecorder) ReadDir(dirname any) *MockFileSystemReadDirCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadDir", reflect.TypeOf((*MockFileSystem)(nil).ReadDir), dirname) + return &MockFileSystemReadDirCall{Call: call} +} - return m.MoveFunc(src, dst) +// MockFileSystemReadDirCall wrap *gomock.Call +type MockFileSystemReadDirCall struct { + *gomock.Call } -// MoveCalled returns true if Move was called at least once. -func (m *FileSystem) MoveCalled() bool { - m.lockMove.Lock() - defer m.lockMove.Unlock() +// Return rewrite *gomock.Call.Return +func (c *MockFileSystemReadDirCall) Return(arg0 []os.DirEntry, arg1 error) *MockFileSystemReadDirCall { + c.Call = c.Call.Return(arg0, arg1) + return c +} - return len(m.calls.Move) > 0 +// Do rewrite *gomock.Call.Do +func (c *MockFileSystemReadDirCall) Do(f func(string) ([]os.DirEntry, error)) *MockFileSystemReadDirCall { + c.Call = c.Call.Do(f) + return c } -// MoveCalls returns the calls made to Move. -func (m *FileSystem) MoveCalls() []struct { - Src string - Dst string -} { - m.lockMove.Lock() - defer m.lockMove.Unlock() +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFileSystemReadDirCall) DoAndReturn(f func(string) ([]os.DirEntry, error)) *MockFileSystemReadDirCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - return m.calls.Move +// Remove mocks base method. +func (m *MockFileSystem) Remove(name string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Remove", name) + ret0, _ := ret[0].(error) + return ret0 } -// NewBufferedReader mocks base method by wrapping the associated func. -func (m *FileSystem) NewBufferedReader(rd io.Reader) github_com_confluentinc_cli_internal_pkg_io.Reader { - m.lockNewBufferedReader.Lock() - defer m.lockNewBufferedReader.Unlock() +// Remove indicates an expected call of Remove. +func (mr *MockFileSystemMockRecorder) Remove(name any) *MockFileSystemRemoveCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Remove", reflect.TypeOf((*MockFileSystem)(nil).Remove), name) + return &MockFileSystemRemoveCall{Call: call} +} - if m.NewBufferedReaderFunc == nil { - panic("mocker: FileSystem.NewBufferedReaderFunc is nil but FileSystem.NewBufferedReader was called.") - } +// MockFileSystemRemoveCall wrap *gomock.Call +type MockFileSystemRemoveCall struct { + *gomock.Call +} - call := struct { - Rd io.Reader - }{ - Rd: rd, - } +// Return rewrite *gomock.Call.Return +func (c *MockFileSystemRemoveCall) Return(arg0 error) *MockFileSystemRemoveCall { + c.Call = c.Call.Return(arg0) + return c +} - m.calls.NewBufferedReader = append(m.calls.NewBufferedReader, call) +// Do rewrite *gomock.Call.Do +func (c *MockFileSystemRemoveCall) Do(f func(string) error) *MockFileSystemRemoveCall { + c.Call = c.Call.Do(f) + return c +} - return m.NewBufferedReaderFunc(rd) +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFileSystemRemoveCall) DoAndReturn(f func(string) error) *MockFileSystemRemoveCall { + c.Call = c.Call.DoAndReturn(f) + return c } -// NewBufferedReaderCalled returns true if NewBufferedReader was called at least once. -func (m *FileSystem) NewBufferedReaderCalled() bool { - m.lockNewBufferedReader.Lock() - defer m.lockNewBufferedReader.Unlock() +// RemoveAll mocks base method. +func (m *MockFileSystem) RemoveAll(path string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RemoveAll", path) + ret0, _ := ret[0].(error) + return ret0 +} - return len(m.calls.NewBufferedReader) > 0 +// RemoveAll indicates an expected call of RemoveAll. +func (mr *MockFileSystemMockRecorder) RemoveAll(path any) *MockFileSystemRemoveAllCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveAll", reflect.TypeOf((*MockFileSystem)(nil).RemoveAll), path) + return &MockFileSystemRemoveAllCall{Call: call} } -// NewBufferedReaderCalls returns the calls made to NewBufferedReader. -func (m *FileSystem) NewBufferedReaderCalls() []struct { - Rd io.Reader -} { - m.lockNewBufferedReader.Lock() - defer m.lockNewBufferedReader.Unlock() +// MockFileSystemRemoveAllCall wrap *gomock.Call +type MockFileSystemRemoveAllCall struct { + *gomock.Call +} - return m.calls.NewBufferedReader +// Return rewrite *gomock.Call.Return +func (c *MockFileSystemRemoveAllCall) Return(arg0 error) *MockFileSystemRemoveAllCall { + c.Call = c.Call.Return(arg0) + return c } -// IsTerminal mocks base method by wrapping the associated func. -func (m *FileSystem) IsTerminal(fd uintptr) bool { - m.lockIsTerminal.Lock() - defer m.lockIsTerminal.Unlock() +// Do rewrite *gomock.Call.Do +func (c *MockFileSystemRemoveAllCall) Do(f func(string) error) *MockFileSystemRemoveAllCall { + c.Call = c.Call.Do(f) + return c +} - if m.IsTerminalFunc == nil { - panic("mocker: FileSystem.IsTerminalFunc is nil but FileSystem.IsTerminal was called.") - } +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFileSystemRemoveAllCall) DoAndReturn(f func(string) error) *MockFileSystemRemoveAllCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - call := struct { - Fd uintptr - }{ - Fd: fd, - } +// Stat mocks base method. +func (m *MockFileSystem) Stat(name string) (os.FileInfo, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Stat", name) + ret0, _ := ret[0].(os.FileInfo) + ret1, _ := ret[1].(error) + return ret0, ret1 +} - m.calls.IsTerminal = append(m.calls.IsTerminal, call) +// Stat indicates an expected call of Stat. +func (mr *MockFileSystemMockRecorder) Stat(name any) *MockFileSystemStatCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Stat", reflect.TypeOf((*MockFileSystem)(nil).Stat), name) + return &MockFileSystemStatCall{Call: call} +} - return m.IsTerminalFunc(fd) +// MockFileSystemStatCall wrap *gomock.Call +type MockFileSystemStatCall struct { + *gomock.Call } -// IsTerminalCalled returns true if IsTerminal was called at least once. -func (m *FileSystem) IsTerminalCalled() bool { - m.lockIsTerminal.Lock() - defer m.lockIsTerminal.Unlock() - - return len(m.calls.IsTerminal) > 0 -} - -// IsTerminalCalls returns the calls made to IsTerminal. -func (m *FileSystem) IsTerminalCalls() []struct { - Fd uintptr -} { - m.lockIsTerminal.Lock() - defer m.lockIsTerminal.Unlock() +// Return rewrite *gomock.Call.Return +func (c *MockFileSystemStatCall) Return(arg0 os.FileInfo, arg1 error) *MockFileSystemStatCall { + c.Call = c.Call.Return(arg0, arg1) + return c +} - return m.calls.IsTerminal +// Do rewrite *gomock.Call.Do +func (c *MockFileSystemStatCall) Do(f func(string) (os.FileInfo, error)) *MockFileSystemStatCall { + c.Call = c.Call.Do(f) + return c } -// Glob mocks base method by wrapping the associated func. -func (m *FileSystem) Glob(pattern string) ([]string, error) { - m.lockGlob.Lock() - defer m.lockGlob.Unlock() - - if m.GlobFunc == nil { - panic("mocker: FileSystem.GlobFunc is nil but FileSystem.Glob was called.") - } - - call := struct { - Pattern string - }{ - Pattern: pattern, - } - - m.calls.Glob = append(m.calls.Glob, call) - - return m.GlobFunc(pattern) -} - -// GlobCalled returns true if Glob was called at least once. -func (m *FileSystem) GlobCalled() bool { - m.lockGlob.Lock() - defer m.lockGlob.Unlock() - - return len(m.calls.Glob) > 0 -} - -// GlobCalls returns the calls made to Glob. -func (m *FileSystem) GlobCalls() []struct { - Pattern string -} { - m.lockGlob.Lock() - defer m.lockGlob.Unlock() - - return m.calls.Glob -} - -// Reset resets the calls made to the mocked methods. -func (m *FileSystem) Reset() { - m.lockOpen.Lock() - m.calls.Open = nil - m.lockOpen.Unlock() - m.lockStat.Lock() - m.calls.Stat = nil - m.lockStat.Unlock() - m.lockCreate.Lock() - m.calls.Create = nil - m.lockCreate.Unlock() - m.lockChtimes.Lock() - m.calls.Chtimes = nil - m.lockChtimes.Unlock() - m.lockChmod.Lock() - m.calls.Chmod = nil - m.lockChmod.Unlock() - m.lockRemove.Lock() - m.calls.Remove = nil - m.lockRemove.Unlock() - m.lockRemoveAll.Lock() - m.calls.RemoveAll = nil - m.lockRemoveAll.Unlock() - m.lockReadDir.Lock() - m.calls.ReadDir = nil - m.lockReadDir.Unlock() - m.lockMkdirTemp.Lock() - m.calls.MkdirTemp = nil - m.lockMkdirTemp.Unlock() - m.lockCopy.Lock() - m.calls.Copy = nil - m.lockCopy.Unlock() - m.lockMove.Lock() - m.calls.Move = nil - m.lockMove.Unlock() - m.lockNewBufferedReader.Lock() - m.calls.NewBufferedReader = nil - m.lockNewBufferedReader.Unlock() - m.lockIsTerminal.Lock() - m.calls.IsTerminal = nil - m.lockIsTerminal.Unlock() - m.lockGlob.Lock() - m.calls.Glob = nil - m.lockGlob.Unlock() +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFileSystemStatCall) DoAndReturn(f func(string) (os.FileInfo, error)) *MockFileSystemStatCall { + c.Call = c.Call.DoAndReturn(f) + return c } diff --git a/pkg/mock/filesystem_pt.go b/pkg/mock/filesystem_pt.go deleted file mode 100644 index e269a2b995..0000000000 --- a/pkg/mock/filesystem_pt.go +++ /dev/null @@ -1,116 +0,0 @@ -package mock - -import ( - "io" - "os" - "time" - - pio "github.com/confluentinc/cli/v4/pkg/io" -) - -// PassThroughFileSystem is useful for optionally mocking some methods -// We have to check whether Mock.Func is nil because our mocks panic-recovery if called with nil func -type PassThroughFileSystem struct { - Mock *FileSystem - FS pio.FileSystem -} - -var _ pio.FileSystem = (*PassThroughFileSystem)(nil) - -func (c *PassThroughFileSystem) Open(name string) (pio.File, error) { - if c.Mock.OpenFunc != nil { - return c.Mock.Open(name) - } - return c.FS.Open(name) -} - -func (c *PassThroughFileSystem) Stat(name string) (os.FileInfo, error) { - if c.Mock.StatFunc != nil { - return c.Mock.Stat(name) - } - return c.FS.Stat(name) -} - -func (c *PassThroughFileSystem) Create(name string) (pio.File, error) { - if c.Mock.CreateFunc != nil { - return c.Mock.Create(name) - } - return c.FS.Create(name) -} - -func (c *PassThroughFileSystem) Chtimes(n string, a, m time.Time) error { - if c.Mock.ChtimesFunc != nil { - return c.Mock.Chtimes(n, a, m) - } - return c.FS.Chtimes(n, a, m) -} - -func (c *PassThroughFileSystem) Chmod(name string, mode os.FileMode) error { - if c.Mock.ChmodFunc != nil { - return c.Mock.Chmod(name, mode) - } - return c.FS.Chmod(name, mode) -} - -func (c *PassThroughFileSystem) Remove(name string) error { - if c.Mock.RemoveFunc != nil { - return c.Mock.Remove(name) - } - return c.FS.Remove(name) -} - -func (c *PassThroughFileSystem) RemoveAll(path string) error { - if c.Mock.RemoveAllFunc != nil { - return c.Mock.RemoveAllFunc(path) - } - return c.FS.RemoveAll(path) -} - -func (c *PassThroughFileSystem) ReadDir(dirname string) ([]os.DirEntry, error) { - if c.Mock.ReadDirFunc != nil { - return c.Mock.ReadDirFunc(dirname) - } - return c.FS.ReadDir(dirname) -} - -func (c *PassThroughFileSystem) MkdirTemp(dir, prefix string) (string, error) { - if c.Mock.MkdirTempFunc != nil { - return c.Mock.MkdirTemp(dir, prefix) - } - return c.FS.MkdirTemp(dir, prefix) -} - -func (c *PassThroughFileSystem) Copy(dst io.Writer, src io.Reader) (int64, error) { - if c.Mock.CopyFunc != nil { - return c.Mock.Copy(dst, src) - } - return c.FS.Copy(dst, src) -} - -func (c *PassThroughFileSystem) Move(src, dst string) error { - if c.Mock.MoveFunc != nil { - return c.Mock.Move(src, dst) - } - return c.FS.Move(src, dst) -} - -func (c *PassThroughFileSystem) NewBufferedReader(rd io.Reader) pio.Reader { - if c.Mock.NewBufferedReaderFunc != nil { - return c.Mock.NewBufferedReader(rd) - } - return c.FS.NewBufferedReader(rd) -} - -func (c *PassThroughFileSystem) IsTerminal(fd uintptr) bool { - if c.Mock.IsTerminalFunc != nil { - return c.Mock.IsTerminal(fd) - } - return c.FS.IsTerminal(fd) -} - -func (c *PassThroughFileSystem) Glob(pattern string) ([]string, error) { - if c.Mock.GlobFunc != nil { - return c.Mock.Glob(pattern) - } - return c.FS.Glob(pattern) -} diff --git a/pkg/mock/prompt.go b/pkg/mock/prompt.go index bbc1d2a8b9..51fcf83ece 100644 --- a/pkg/mock/prompt.go +++ b/pkg/mock/prompt.go @@ -1,145 +1,157 @@ -// Code generated by mocker. DO NOT EDIT. -// github.com/travisjeffery/mocker -// Source: prompt.go - +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/confluentinc/cli/v4/pkg/form (interfaces: Prompt) +// +// Generated by this command: +// +// mockgen -typed -destination=../mock/prompt.go -package=mock github.com/confluentinc/cli/v4/pkg/form Prompt +// + +// Package mock is a generated GoMock package. package mock import ( - sync "sync" -) - -// Prompt is a mock of Prompt interface -type Prompt struct { - lockReadLine sync.Mutex - ReadLineFunc func() (string, error) + reflect "reflect" - lockReadLineMasked sync.Mutex - ReadLineMaskedFunc func() (string, error) - - lockIsPipe sync.Mutex - IsPipeFunc func() (bool, error) + gomock "go.uber.org/mock/gomock" +) - calls struct { - ReadLine []struct { - } - ReadLineMasked []struct { - } - IsPipe []struct { - } - } +// MockPrompt is a mock of Prompt interface. +type MockPrompt struct { + ctrl *gomock.Controller + recorder *MockPromptMockRecorder + isgomock struct{} } -// ReadLine mocks base method by wrapping the associated func. -func (m *Prompt) ReadLine() (string, error) { - m.lockReadLine.Lock() - defer m.lockReadLine.Unlock() - - if m.ReadLineFunc == nil { - panic("mocker: Prompt.ReadLineFunc is nil but Prompt.ReadLine was called.") - } - - call := struct { - }{} - - m.calls.ReadLine = append(m.calls.ReadLine, call) - - return m.ReadLineFunc() +// MockPromptMockRecorder is the mock recorder for MockPrompt. +type MockPromptMockRecorder struct { + mock *MockPrompt } -// ReadLineCalled returns true if ReadLine was called at least once. -func (m *Prompt) ReadLineCalled() bool { - m.lockReadLine.Lock() - defer m.lockReadLine.Unlock() - - return len(m.calls.ReadLine) > 0 +// NewMockPrompt creates a new mock instance. +func NewMockPrompt(ctrl *gomock.Controller) *MockPrompt { + mock := &MockPrompt{ctrl: ctrl} + mock.recorder = &MockPromptMockRecorder{mock} + return mock } -// ReadLineCalls returns the calls made to ReadLine. -func (m *Prompt) ReadLineCalls() []struct { -} { - m.lockReadLine.Lock() - defer m.lockReadLine.Unlock() - - return m.calls.ReadLine +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockPrompt) EXPECT() *MockPromptMockRecorder { + return m.recorder } -// ReadLineMasked mocks base method by wrapping the associated func. -func (m *Prompt) ReadLineMasked() (string, error) { - m.lockReadLineMasked.Lock() - defer m.lockReadLineMasked.Unlock() - - if m.ReadLineMaskedFunc == nil { - panic("mocker: Prompt.ReadLineMaskedFunc is nil but Prompt.ReadLineMasked was called.") - } +// IsPipe mocks base method. +func (m *MockPrompt) IsPipe() (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsPipe") + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} - call := struct { - }{} +// IsPipe indicates an expected call of IsPipe. +func (mr *MockPromptMockRecorder) IsPipe() *MockPromptIsPipeCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsPipe", reflect.TypeOf((*MockPrompt)(nil).IsPipe)) + return &MockPromptIsPipeCall{Call: call} +} - m.calls.ReadLineMasked = append(m.calls.ReadLineMasked, call) +// MockPromptIsPipeCall wrap *gomock.Call +type MockPromptIsPipeCall struct { + *gomock.Call +} - return m.ReadLineMaskedFunc() +// Return rewrite *gomock.Call.Return +func (c *MockPromptIsPipeCall) Return(arg0 bool, arg1 error) *MockPromptIsPipeCall { + c.Call = c.Call.Return(arg0, arg1) + return c } -// ReadLineMaskedCalled returns true if ReadLineMasked was called at least once. -func (m *Prompt) ReadLineMaskedCalled() bool { - m.lockReadLineMasked.Lock() - defer m.lockReadLineMasked.Unlock() +// Do rewrite *gomock.Call.Do +func (c *MockPromptIsPipeCall) Do(f func() (bool, error)) *MockPromptIsPipeCall { + c.Call = c.Call.Do(f) + return c +} - return len(m.calls.ReadLineMasked) > 0 +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockPromptIsPipeCall) DoAndReturn(f func() (bool, error)) *MockPromptIsPipeCall { + c.Call = c.Call.DoAndReturn(f) + return c } -// ReadLineMaskedCalls returns the calls made to ReadLineMasked. -func (m *Prompt) ReadLineMaskedCalls() []struct { -} { - m.lockReadLineMasked.Lock() - defer m.lockReadLineMasked.Unlock() +// ReadLine mocks base method. +func (m *MockPrompt) ReadLine() (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReadLine") + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} - return m.calls.ReadLineMasked +// ReadLine indicates an expected call of ReadLine. +func (mr *MockPromptMockRecorder) ReadLine() *MockPromptReadLineCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadLine", reflect.TypeOf((*MockPrompt)(nil).ReadLine)) + return &MockPromptReadLineCall{Call: call} } -// IsPipe mocks base method by wrapping the associated func. -func (m *Prompt) IsPipe() (bool, error) { - m.lockIsPipe.Lock() - defer m.lockIsPipe.Unlock() +// MockPromptReadLineCall wrap *gomock.Call +type MockPromptReadLineCall struct { + *gomock.Call +} - if m.IsPipeFunc == nil { - panic("mocker: Prompt.IsPipeFunc is nil but Prompt.IsPipe was called.") - } +// Return rewrite *gomock.Call.Return +func (c *MockPromptReadLineCall) Return(arg0 string, arg1 error) *MockPromptReadLineCall { + c.Call = c.Call.Return(arg0, arg1) + return c +} - call := struct { - }{} +// Do rewrite *gomock.Call.Do +func (c *MockPromptReadLineCall) Do(f func() (string, error)) *MockPromptReadLineCall { + c.Call = c.Call.Do(f) + return c +} - m.calls.IsPipe = append(m.calls.IsPipe, call) +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockPromptReadLineCall) DoAndReturn(f func() (string, error)) *MockPromptReadLineCall { + c.Call = c.Call.DoAndReturn(f) + return c +} - return m.IsPipeFunc() +// ReadLineMasked mocks base method. +func (m *MockPrompt) ReadLineMasked() (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReadLineMasked") + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 } -// IsPipeCalled returns true if IsPipe was called at least once. -func (m *Prompt) IsPipeCalled() bool { - m.lockIsPipe.Lock() - defer m.lockIsPipe.Unlock() +// ReadLineMasked indicates an expected call of ReadLineMasked. +func (mr *MockPromptMockRecorder) ReadLineMasked() *MockPromptReadLineMaskedCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadLineMasked", reflect.TypeOf((*MockPrompt)(nil).ReadLineMasked)) + return &MockPromptReadLineMaskedCall{Call: call} +} - return len(m.calls.IsPipe) > 0 +// MockPromptReadLineMaskedCall wrap *gomock.Call +type MockPromptReadLineMaskedCall struct { + *gomock.Call } -// IsPipeCalls returns the calls made to IsPipe. -func (m *Prompt) IsPipeCalls() []struct { -} { - m.lockIsPipe.Lock() - defer m.lockIsPipe.Unlock() +// Return rewrite *gomock.Call.Return +func (c *MockPromptReadLineMaskedCall) Return(arg0 string, arg1 error) *MockPromptReadLineMaskedCall { + c.Call = c.Call.Return(arg0, arg1) + return c +} - return m.calls.IsPipe +// Do rewrite *gomock.Call.Do +func (c *MockPromptReadLineMaskedCall) Do(f func() (string, error)) *MockPromptReadLineMaskedCall { + c.Call = c.Call.Do(f) + return c } -// Reset resets the calls made to the mocked methods. -func (m *Prompt) Reset() { - m.lockReadLine.Lock() - m.calls.ReadLine = nil - m.lockReadLine.Unlock() - m.lockReadLineMasked.Lock() - m.calls.ReadLineMasked = nil - m.lockReadLineMasked.Unlock() - m.lockIsPipe.Lock() - m.calls.IsPipe = nil - m.lockIsPipe.Unlock() +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockPromptReadLineMaskedCall) DoAndReturn(f func() (string, error)) *MockPromptReadLineMaskedCall { + c.Call = c.Call.DoAndReturn(f) + return c } From f40d67762ab97bb6c66a811625d7c23c6b4963ba Mon Sep 17 00:00:00 2001 From: Dave Shoup Date: Fri, 21 Aug 2026 16:58:47 -0400 Subject: [PATCH 2/2] empty commit for CI