Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
134 changes: 52 additions & 82 deletions internal/local/command_services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"

climock "github.com/confluentinc/cli/v4/mock"
)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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()
Expand All @@ -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()
Expand Down
Loading