From 87f63cf27fc6f38a6a6e10c956a8c3264c7d6ca7 Mon Sep 17 00:00:00 2001 From: Daniel Weinshenker Date: Wed, 1 Nov 2023 16:13:54 -0700 Subject: [PATCH] add tests and mocks --- commands/databases.go | 97 +++++++-------- commands/databases_test.go | 208 ++++++++++++++++++++++++++++++++ commands/displayers/database.go | 2 +- do/mocks/DatabasesService.go | 73 +++++++++++ 4 files changed, 328 insertions(+), 52 deletions(-) diff --git a/commands/databases.go b/commands/databases.go index 787c9ce21..a444d84c3 100644 --- a/commands/databases.go +++ b/commands/databases.go @@ -1610,23 +1610,21 @@ func RunDatabaseTopicCreate(c *CmdConfig) error { databaseID := c.Args[0] topicName := c.Args[1] + createReq := &godo.DatabaseCreateTopicRequest{Name: topicName} + pc, err := c.Doit.GetInt(c.NS, doctl.ArgDatabaseTopicPartitionCount) - if err != nil { - return err + if err == nil && pc != 0 { + pcUInt32 := uint32(pc) + createReq.PartitionCount = &pcUInt32 } - pcUInt32 := uint32(pc) rf, err := c.Doit.GetInt(c.NS, doctl.ArgDatabaseTopicReplicationFactor) - if err != nil { - return err + if err == nil && rf != 0 { + rfUInt32 := uint32(rf) + createReq.ReplicationFactor = &rfUInt32 } - rfUInt32 := uint32(rf) + createReq.Config = getDatabaseTopicConfigArgs(c) - _, err = c.Databases().CreateTopic(databaseID, &godo.DatabaseCreateTopicRequest{ - Name: topicName, - ReplicationFactor: &rfUInt32, - PartitionCount: &pcUInt32, - Config: getDatabaseTopicConfigArgs(c), - }) + _, err = c.Databases().CreateTopic(databaseID, createReq) return err } @@ -1638,22 +1636,21 @@ func RunDatabaseTopicUpdate(c *CmdConfig) error { databaseID := c.Args[0] topicName := c.Args[1] + updateReq := &godo.DatabaseUpdateTopicRequest{} + pc, err := c.Doit.GetInt(c.NS, doctl.ArgDatabaseTopicPartitionCount) - if err != nil { - return err + if err == nil && pc != 0 { + pcUInt32 := uint32(pc) + updateReq.PartitionCount = &pcUInt32 } - pcUInt32 := uint32(pc) rf, err := c.Doit.GetInt(c.NS, doctl.ArgDatabaseTopicReplicationFactor) - if err != nil { - return err + if err == nil && rf != 0 { + rfUInt32 := uint32(rf) + updateReq.ReplicationFactor = &rfUInt32 } - rfUInt32 := uint32(rf) + updateReq.Config = getDatabaseTopicConfigArgs(c) - err = c.Databases().UpdateTopic(databaseID, topicName, &godo.DatabaseUpdateTopicRequest{ - ReplicationFactor: &rfUInt32, - PartitionCount: &pcUInt32, - Config: getDatabaseTopicConfigArgs(c), - }) + err = c.Databases().UpdateTopic(databaseID, topicName, updateReq) return err } @@ -1664,72 +1661,72 @@ func getDatabaseTopicConfigArgs(c *CmdConfig) *godo.TopicConfig { res.CleanupPolicy = val } val, err = c.Doit.GetString(c.NS, doctl.ArgDatabaseTopicCompressionType) - if err == nil { + if err == nil && val != "" { res.CompressionType = val } val, err = c.Doit.GetString(c.NS, doctl.ArgDatabaseTopicDeleteRetentionMS) - if err == nil { + if err == nil && val != "" { i, err := strconv.ParseUint(val, 10, 64) if err == nil { res.DeleteRetentionMS = &i } } val, err = c.Doit.GetString(c.NS, doctl.ArgDatabaseTopicFileDeleteDelayMS) - if err == nil { + if err == nil && val != "" { i, err := strconv.ParseUint(val, 10, 64) if err == nil { res.FileDeleteDelayMS = &i } } val, err = c.Doit.GetString(c.NS, doctl.ArgDatabaseTopicFlushMessages) - if err == nil { + if err == nil && val != "" { i, err := strconv.ParseUint(val, 10, 64) if err == nil { res.FlushMessages = &i } } val, err = c.Doit.GetString(c.NS, doctl.ArgDatabaseTopicFlushMS) - if err == nil { + if err == nil && val != "" { i, err := strconv.ParseUint(val, 10, 64) if err == nil { res.FlushMS = &i } } val, err = c.Doit.GetString(c.NS, doctl.ArgDatabaseTopicIntervalIndexBytes) - if err == nil { + if err == nil && val != "" { i, err := strconv.ParseUint(val, 10, 64) if err == nil { res.IndexIntervalBytes = &i } } val, err = c.Doit.GetString(c.NS, doctl.ArgDatabaseTopicMaxCompactionLagMS) - if err == nil { + if err == nil && val != "" { i, err := strconv.ParseUint(val, 10, 64) if err == nil { res.MaxCompactionLagMS = &i } } val, err = c.Doit.GetString(c.NS, doctl.ArgDatabaseTopicMaxMessageBytes) - if err == nil { + if err == nil && val != "" { i, err := strconv.ParseUint(val, 10, 64) if err == nil { res.MaxMessageBytes = &i } } bVal, err := c.Doit.GetBoolPtr(c.NS, doctl.ArgDatabaseTopicMesssageDownConversionEnable) - if err == nil { + if err == nil && bVal != nil { res.MessageDownConversionEnable = bVal } val, err = c.Doit.GetString(c.NS, doctl.ArgDatabaseTopicMessageFormatVersion) - if err == nil { + if err == nil && val != "" { res.MessageFormatVersion = val } val, err = c.Doit.GetString(c.NS, doctl.ArgDatabaseTopicMessageTimestampType) - if err == nil { + if err == nil && val != "" { res.MessageTimestampType = val } val, err = c.Doit.GetString(c.NS, doctl.ArgDatabaseTopicMinCleanableDirtyRatio) - if err == nil { + if err == nil && val != "" { i, err := strconv.ParseFloat(val, 32) if err == nil { iFloat32 := float32(i) @@ -1737,14 +1734,14 @@ func getDatabaseTopicConfigArgs(c *CmdConfig) *godo.TopicConfig { } } val, err = c.Doit.GetString(c.NS, doctl.ArgDatabaseTopicMinCompactionLagMS) - if err == nil { + if err == nil && val != "" { i, err := strconv.ParseUint(val, 10, 64) if err == nil { res.MinCompactionLagMS = &i } } val, err = c.Doit.GetString(c.NS, doctl.ArgDatabaseTopicMinInsyncReplicas) - if err == nil { + if err == nil && val != "" { i, err := strconv.ParseUint(val, 10, 32) if err == nil { iUint32 := uint32(i) @@ -1752,46 +1749,46 @@ func getDatabaseTopicConfigArgs(c *CmdConfig) *godo.TopicConfig { } } bVal, err = c.Doit.GetBoolPtr(c.NS, doctl.ArgDatabaseTopicPreallocate) - if err == nil { + if err == nil && bVal != nil { res.Preallocate = bVal } val, err = c.Doit.GetString(c.NS, doctl.ArgDatabaseTopicRetentionBytes) - if err == nil { + if err == nil && val != "" { i, err := strconv.ParseInt(val, 10, 64) if err == nil { res.RetentionBytes = &i } } val, err = c.Doit.GetString(c.NS, doctl.ArgDatabaseTopicRetentionMS) - if err == nil { + if err == nil && val != "" { i, err := strconv.ParseInt(val, 10, 64) if err == nil { res.RetentionMS = &i } } val, err = c.Doit.GetString(c.NS, doctl.ArgDatabaseTopicSegmentBytes) - if err == nil { + if err == nil && val != "" { i, err := strconv.ParseUint(val, 10, 64) if err == nil { res.SegmentBytes = &i } } val, err = c.Doit.GetString(c.NS, doctl.ArgDatabaseTopicSegmentJitterMS) - if err == nil { + if err == nil && val != "" { i, err := strconv.ParseUint(val, 10, 64) if err == nil { res.SegmentJitterMS = &i } } val, err = c.Doit.GetString(c.NS, doctl.ArgDatabaseTopicSegmentMS) - if err == nil { + if err == nil && val != "" { i, err := strconv.ParseUint(val, 10, 64) if err == nil { res.SegmentMS = &i } } bVal, err = c.Doit.GetBoolPtr(c.NS, doctl.ArgDatabaseTopicUncleanLeaderElectionEnable) - if err == nil { + if err == nil && bVal != nil { res.UncleanLeaderElectionEnable = bVal } @@ -1811,7 +1808,7 @@ func databaseTopic() *Command { This command lists the following details for each topic in a kafka database cluster: - The Name of the topic. - - The State of the topic - The possible values are: "topicstate_active", "configuring", "deleting". + - The State of the topic. - The Replication Factor of the topic - number of brokers the topic's partitions are replicated across. ` @@ -1834,8 +1831,8 @@ This command lists the following details for each partition of a given topic in - The EarliestOffset - earliest offset read amongst all consumers of the partition. ` - CmdBuilder(cmd, RunDatabaseTopicList, "list ", "Retrieve a list of topics for a given kafka database", topicListDetails, Writer, aliasOpt("ls")) - CmdBuilder(cmd, RunDatabaseTopicGet, "get ", "Retrieve the configuration for a given kafka topic", topicGetDetails, Writer, aliasOpt("g")) + CmdBuilder(cmd, RunDatabaseTopicList, "list ", "Retrieve a list of topics for a given kafka database", topicListDetails, Writer, displayerType(&displayers.DatabaseKafkaTopics{}), aliasOpt("ls")) + CmdBuilder(cmd, RunDatabaseTopicGet, "get ", "Retrieve the configuration for a given kafka topic", topicGetDetails, Writer, displayerType(&displayers.DatabaseKafkaTopic{}), aliasOpt("g")) CmdBuilder(cmd, RunDatabaseTopicListPartition, "partitions ", "Retrieve the partitions for a given kafka topic", topicGetPartitionDetails, Writer, aliasOpt("p")) cmdDatabaseTopicDelete := CmdBuilder(cmd, RunDatabaseTopicDelete, "delete ", "Deletes a kafka topic by topic name", "", Writer, aliasOpt("rm")) AddBoolFlag(cmdDatabaseTopicDelete, doctl.ArgForce, doctl.ArgShortForce, false, "Deletes the kafka topic without a confirmation prompt") @@ -1868,13 +1865,11 @@ This command lists the following details for each partition of a given topic in AddBoolFlag(c, doctl.ArgDatabaseTopicMesssageDownConversionEnable, "", true, "Specifies whether down-conversion of message formats is enabled to satisfy consumer requests") AddStringFlag(c, doctl.ArgDatabaseTopicMessageFormatVersion, "", "", - `Specifies the message format version used by the broker to append messages to the logs. By setting a format version, all existing messages on disk must be - smaller or equal to the specified version`) + "Specifies the message format version used by the broker to append messages to the logs. By setting a format version, all existing messages on disk must be smaller or equal to the specified version") AddStringFlag(c, doctl.ArgDatabaseTopicMessageTimestampType, "", "", "Specifies whether to use the create time or log append time as the timestamp on a message") AddStringFlag(c, doctl.ArgDatabaseTopicMinCleanableDirtyRatio, "", "", - `Specifies the frequenty of log compaction (if enabled) in relation to duplicates present in the logs. For example, 0.5 would mean at most half of the log - could be duplicates before compaction would begin`) + "Specifies the frequenty of log compaction (if enabled) in relation to duplicates present in the logs. For example, 0.5 would mean at most half of the log could be duplicates before compaction would begin") AddStringFlag(c, doctl.ArgDatabaseTopicMinCompactionLagMS, "", "", "Specifies the minimum time (in ms) that a message will remain uncompacted. This is only applicable if the logs have compaction enabled") AddStringFlag(c, doctl.ArgDatabaseTopicMinInsyncReplicas, "", "", diff --git a/commands/databases_test.go b/commands/databases_test.go index 4b9e52ba6..5f323288b 100644 --- a/commands/databases_test.go +++ b/commands/databases_test.go @@ -65,6 +65,21 @@ var ( }, } + testKafkaDBCluster = do.Database{ + Database: &godo.Database{ + ID: "ea93928g-8se0-929e-m1ns-029daj2k3j12", + Name: "kafka-db-cluster", + RegionSlug: "nyc1", + EngineSlug: "kafka", + VersionSlug: "3.5", + NumNodes: 3, + SizeSlug: "db-s-2vcpu-4gb", + CreatedAt: time.Now(), + Status: "online", + Tags: []string{"testing"}, + }, + } + testDBBackUpCluster = do.Database{ Database: &godo.Database{ ID: "ea4652de-4fe0-11e9-b7ab-df1ef30eab9e", @@ -189,6 +204,36 @@ var ( RedisConfig: &godo.RedisConfig{}, } + topicReplicationFactor = uint32(3) + testKafkaTopic = do.DatabaseTopic{ + DatabaseTopic: &godo.DatabaseTopic{ + Name: "topic1", + State: "active", + Config: &godo.TopicConfig{ + CleanupPolicy: "delete", + }, + Partitions: []*godo.TopicPartition{ + { + Id: 0, + Size: 4096, + EarliestOffset: 0, + InSyncReplicas: 2, + }, + { + Id: 1, + Size: 4096, + EarliestOffset: 4, + InSyncReplicas: 2, + }, + }, + ReplicationFactor: &topicReplicationFactor, + }, + } + + testKafkaTopics = do.DatabaseTopics{ + testKafkaTopic, + } + errTest = errors.New("error") ) @@ -214,6 +259,7 @@ func TestDatabasesCommand(t *testing.T) { "db", "sql-mode", "configuration", + "topics", ) } @@ -290,6 +336,19 @@ func TestDatabaseConfigurationCommand(t *testing.T) { assertCommandNames(t, cmd, "get") } +func TestDatabaseKafkaTopicCommand(t *testing.T) { + cmd := databaseTopic() + assert.NotNil(t, cmd) + assertCommandNames(t, cmd, + "get", + "list", + "delete", + "create", + "update", + "partitions", + ) +} + func TestDatabasesGet(t *testing.T) { // Successful call withTestClient(t, func(config *CmdConfig, tm *tcMocks) { @@ -554,6 +613,155 @@ func TestDatabaseListBackups(t *testing.T) { }) } +func TestDatabaseListKafkaTopics(t *testing.T) { + // Success + withTestClient(t, func(config *CmdConfig, tm *tcMocks) { + tm.databases.EXPECT().ListTopics(testKafkaDBCluster.ID).Return(testKafkaTopics, nil) + config.Args = append(config.Args, testKafkaDBCluster.ID) + + err := RunDatabaseTopicList(config) + assert.NoError(t, err) + }) + + // Error + withTestClient(t, func(config *CmdConfig, tm *tcMocks) { + tm.databases.EXPECT().ListTopics(testKafkaDBCluster.ID).Return(nil, errTest) + config.Args = append(config.Args, testKafkaDBCluster.ID) + + err := RunDatabaseTopicList(config) + assert.EqualError(t, err, errTest.Error()) + }) +} + +func TestDatabaseGetKafkaTopic(t *testing.T) { + // Success + withTestClient(t, func(config *CmdConfig, tm *tcMocks) { + tm.databases.EXPECT().GetTopic(testKafkaDBCluster.ID, testKafkaTopic.Name).Return(&testKafkaTopic, nil) + config.Args = append(config.Args, testKafkaDBCluster.ID, testKafkaTopic.Name) + + err := RunDatabaseTopicGet(config) + assert.NoError(t, err) + }) + + // Error + withTestClient(t, func(config *CmdConfig, tm *tcMocks) { + tm.databases.EXPECT().GetTopic(testKafkaDBCluster.ID, testKafkaTopic.Name).Return(nil, errTest) + config.Args = append(config.Args, testKafkaDBCluster.ID, testKafkaTopic.Name) + + err := RunDatabaseTopicGet(config) + assert.EqualError(t, err, errTest.Error()) + }) +} + +func TestDatabaseCreateKafkaTopic(t *testing.T) { + // Success - only topic name + withTestClient(t, func(config *CmdConfig, tm *tcMocks) { + createReq := &godo.DatabaseCreateTopicRequest{ + Name: testKafkaTopic.Name, + Config: &godo.TopicConfig{}, + } + tm.databases.EXPECT().CreateTopic(testKafkaDBCluster.ID, createReq).Return(&testKafkaTopic, nil) + config.Args = append(config.Args, testKafkaDBCluster.ID, testKafkaTopic.Name) + + err := RunDatabaseTopicCreate(config) + assert.NoError(t, err) + }) + // Success - with additional config + withTestClient(t, func(config *CmdConfig, tm *tcMocks) { + pc := uint32(len(testKafkaTopic.Partitions)) + createReq := &godo.DatabaseCreateTopicRequest{ + Name: testKafkaTopic.Name, + ReplicationFactor: testKafkaTopic.ReplicationFactor, + PartitionCount: &pc, + Config: &godo.TopicConfig{ + CleanupPolicy: testKafkaTopic.Config.CleanupPolicy, + }, + } + tm.databases.EXPECT().CreateTopic(testKafkaDBCluster.ID, createReq).Return(&testKafkaTopic, nil) + config.Args = append(config.Args, testKafkaDBCluster.ID, testKafkaTopic.Name) + config.Doit.Set(config.NS, doctl.ArgDatabaseTopicPartitionCount, pc) + config.Doit.Set(config.NS, doctl.ArgDatabaseTopicReplicationFactor, testKafkaTopic.ReplicationFactor) + config.Doit.Set(config.NS, doctl.ArgDatabaseTopicCleanupPolicy, testKafkaTopic.Config.CleanupPolicy) + + err := RunDatabaseTopicCreate(config) + assert.NoError(t, err) + }) + // Error + withTestClient(t, func(config *CmdConfig, tm *tcMocks) { + tm.databases.EXPECT().CreateTopic(testKafkaDBCluster.ID, gomock.AssignableToTypeOf(&godo.DatabaseCreateTopicRequest{})).Return(nil, errTest) + config.Args = append(config.Args, testKafkaDBCluster.ID, testKafkaTopic.Name) + + err := RunDatabaseTopicCreate(config) + assert.EqualError(t, err, errTest.Error()) + }) +} + +func TestDatabaseUpdateKafkaTopic(t *testing.T) { + // Success - only partition count + withTestClient(t, func(config *CmdConfig, tm *tcMocks) { + currPC := uint32(len(testKafkaTopic.Partitions)) + newPC := currPC + 1 + updateReq := &godo.DatabaseUpdateTopicRequest{ + PartitionCount: &newPC, + Config: &godo.TopicConfig{}, + } + tm.databases.EXPECT().UpdateTopic(testKafkaDBCluster.ID, testKafkaTopic.Name, updateReq).Return(nil) + config.Args = append(config.Args, testKafkaDBCluster.ID, testKafkaTopic.Name) + config.Doit.Set(config.NS, doctl.ArgDatabaseTopicPartitionCount, newPC) + + err := RunDatabaseTopicUpdate(config) + assert.NoError(t, err) + }) + // Success - with additional config + withTestClient(t, func(config *CmdConfig, tm *tcMocks) { + currPC := uint32(len(testKafkaTopic.Partitions)) + newPC := currPC + 1 + updateReq := &godo.DatabaseUpdateTopicRequest{ + PartitionCount: &newPC, + Config: &godo.TopicConfig{ + CleanupPolicy: testKafkaTopic.Config.CleanupPolicy, + }, + } + tm.databases.EXPECT().UpdateTopic(testKafkaDBCluster.ID, testKafkaTopic.Name, updateReq).Return(nil) + config.Args = append(config.Args, testKafkaDBCluster.ID, testKafkaTopic.Name) + config.Doit.Set(config.NS, doctl.ArgDatabaseTopicPartitionCount, newPC) + config.Doit.Set(config.NS, doctl.ArgDatabaseTopicCleanupPolicy, testKafkaTopic.Config.CleanupPolicy) + + err := RunDatabaseTopicUpdate(config) + assert.NoError(t, err) + }) + // Error + withTestClient(t, func(config *CmdConfig, tm *tcMocks) { + tm.databases.EXPECT().UpdateTopic(testKafkaDBCluster.ID, testKafkaTopic.Name, gomock.AssignableToTypeOf(&godo.DatabaseUpdateTopicRequest{})).Return(errTest) + config.Args = append(config.Args, testKafkaDBCluster.ID, testKafkaTopic.Name) + + err := RunDatabaseTopicUpdate(config) + assert.EqualError(t, err, errTest.Error()) + }) +} + +func TestDatabaseDeleteKafkaTopic(t *testing.T) { + // Successful + withTestClient(t, func(config *CmdConfig, tm *tcMocks) { + tm.databases.EXPECT().DeleteTopic(testKafkaDBCluster.ID, testKafkaTopic.Name).Return(nil) + config.Args = append(config.Args, testKafkaDBCluster.ID, testKafkaTopic.Name) + config.Doit.Set(config.NS, doctl.ArgForce, "true") + + err := RunDatabaseTopicDelete(config) + assert.NoError(t, err) + }) + // Error + withTestClient(t, func(config *CmdConfig, tm *tcMocks) { + tm.databases.EXPECT().DeleteTopic(testKafkaDBCluster.ID, testKafkaTopic.Name).Return(errTest) + + config.Args = append(config.Args, testKafkaDBCluster.ID, testKafkaTopic.Name) + config.Doit.Set(config.NS, doctl.ArgForce, "true") + + err := RunDatabaseTopicDelete(config) + assert.EqualError(t, err, errTest.Error()) + }) +} + func TestDatabaseConnectionGet(t *testing.T) { // Success withTestClient(t, func(config *CmdConfig, tm *tcMocks) { diff --git a/commands/displayers/database.go b/commands/displayers/database.go index 207f56fb6..257de05ba 100644 --- a/commands/displayers/database.go +++ b/commands/displayers/database.go @@ -907,7 +907,7 @@ func (dt *DatabaseKafkaTopic) KV() []map[string]interface{} { if t.Config.MinCompactionLagMS != nil { cfg = append(cfg, map[string]interface{}{ "key": "MinCompactionLagMS", - "value": t.Config.MinCompactionLagMS, + "value": *t.Config.MinCompactionLagMS, }) } if t.Config.MinInsyncReplicas != nil { diff --git a/do/mocks/DatabasesService.go b/do/mocks/DatabasesService.go index 518c339aa..37e926bfb 100644 --- a/do/mocks/DatabasesService.go +++ b/do/mocks/DatabasesService.go @@ -99,6 +99,21 @@ func (mr *MockDatabasesServiceMockRecorder) CreateReplica(arg0, arg1 any) *gomoc return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateReplica", reflect.TypeOf((*MockDatabasesService)(nil).CreateReplica), arg0, arg1) } +// CreateTopic mocks base method. +func (m *MockDatabasesService) CreateTopic(arg0 string, arg1 *godo.DatabaseCreateTopicRequest) (*do.DatabaseTopic, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateTopic", arg0, arg1) + ret0, _ := ret[0].(*do.DatabaseTopic) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateTopic indicates an expected call of CreateTopic. +func (mr *MockDatabasesServiceMockRecorder) CreateTopic(arg0, arg1 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateTopic", reflect.TypeOf((*MockDatabasesService)(nil).CreateTopic), arg0, arg1) +} + // CreateUser mocks base method. func (m *MockDatabasesService) CreateUser(arg0 string, arg1 *godo.DatabaseCreateUserRequest) (*do.DatabaseUser, error) { m.ctrl.T.Helper() @@ -170,6 +185,20 @@ func (mr *MockDatabasesServiceMockRecorder) DeleteReplica(arg0, arg1 any) *gomoc return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteReplica", reflect.TypeOf((*MockDatabasesService)(nil).DeleteReplica), arg0, arg1) } +// DeleteTopic mocks base method. +func (m *MockDatabasesService) DeleteTopic(arg0, arg1 string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteTopic", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteTopic indicates an expected call of DeleteTopic. +func (mr *MockDatabasesServiceMockRecorder) DeleteTopic(arg0, arg1 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteTopic", reflect.TypeOf((*MockDatabasesService)(nil).DeleteTopic), arg0, arg1) +} + // DeleteUser mocks base method. func (m *MockDatabasesService) DeleteUser(arg0, arg1 string) error { m.ctrl.T.Helper() @@ -364,6 +393,21 @@ func (mr *MockDatabasesServiceMockRecorder) GetSQLMode(arg0 any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSQLMode", reflect.TypeOf((*MockDatabasesService)(nil).GetSQLMode), arg0) } +// GetTopic mocks base method. +func (m *MockDatabasesService) GetTopic(arg0, arg1 string) (*do.DatabaseTopic, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTopic", arg0, arg1) + ret0, _ := ret[0].(*do.DatabaseTopic) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetTopic indicates an expected call of GetTopic. +func (mr *MockDatabasesServiceMockRecorder) GetTopic(arg0, arg1 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTopic", reflect.TypeOf((*MockDatabasesService)(nil).GetTopic), arg0, arg1) +} + // GetUser mocks base method. func (m *MockDatabasesService) GetUser(arg0, arg1 string) (*do.DatabaseUser, error) { m.ctrl.T.Helper() @@ -469,6 +513,21 @@ func (mr *MockDatabasesServiceMockRecorder) ListReplicas(arg0 any) *gomock.Call return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListReplicas", reflect.TypeOf((*MockDatabasesService)(nil).ListReplicas), arg0) } +// ListTopics mocks base method. +func (m *MockDatabasesService) ListTopics(arg0 string) (do.DatabaseTopics, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ListTopics", arg0) + ret0, _ := ret[0].(do.DatabaseTopics) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListTopics indicates an expected call of ListTopics. +func (mr *MockDatabasesServiceMockRecorder) ListTopics(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListTopics", reflect.TypeOf((*MockDatabasesService)(nil).ListTopics), arg0) +} + // ListUsers mocks base method. func (m *MockDatabasesService) ListUsers(arg0 string) (do.DatabaseUsers, error) { m.ctrl.T.Helper() @@ -587,3 +646,17 @@ func (mr *MockDatabasesServiceMockRecorder) UpdateMaintenance(arg0, arg1 any) *g mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateMaintenance", reflect.TypeOf((*MockDatabasesService)(nil).UpdateMaintenance), arg0, arg1) } + +// UpdateTopic mocks base method. +func (m *MockDatabasesService) UpdateTopic(arg0, arg1 string, arg2 *godo.DatabaseUpdateTopicRequest) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateTopic", arg0, arg1, arg2) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateTopic indicates an expected call of UpdateTopic. +func (mr *MockDatabasesServiceMockRecorder) UpdateTopic(arg0, arg1, arg2 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateTopic", reflect.TypeOf((*MockDatabasesService)(nil).UpdateTopic), arg0, arg1, arg2) +}