Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
taylanisikdemir committed Feb 22, 2024
1 parent 6913001 commit c6c27d4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
3 changes: 3 additions & 0 deletions common/persistence/nosql/nosqlplugin/cassandra/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ type cdb struct {

var _ nosqlplugin.DB = (*cdb)(nil)

// cassandraDBOption is used to provide optional settings for cdb object
type cassandraDBOption func(*cdb)

// dbWithClient returns a cdb option to set the gocql client.
// If this is not used then the globally registered client is used.
func dbWithClient(client gocql.Client) cassandraDBOption {
return func(db *cdb) {
db.client = client
Expand Down
30 changes: 20 additions & 10 deletions common/persistence/nosql/nosqlplugin/cassandra/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,30 @@ func TestCDBBasics(t *testing.T) {
t.Errorf("got plugin name: %v but want %v", db.PluginName(), PluginName)
}

client.EXPECT().IsNotFoundError(nil).Times(1)
db.IsNotFoundError(nil)
client.EXPECT().IsNotFoundError(nil).Return(true).Times(1)
if db.IsNotFoundError(nil) != true {
t.Errorf("IsNotFoundError returned false but want true")
}

client.EXPECT().IsTimeoutError(nil).Times(1)
db.IsTimeoutError(nil)
client.EXPECT().IsTimeoutError(nil).Return(true).Times(1)
if db.IsTimeoutError(nil) != true {
t.Errorf("IsTimeoutError returned false but want true")
}

client.EXPECT().IsThrottlingError(nil).Times(1)
db.IsThrottlingError(nil)
client.EXPECT().IsThrottlingError(nil).Return(true).Times(1)
if db.IsThrottlingError(nil) != true {
t.Errorf("IsNotFoundError returned false but want true")
}

client.EXPECT().IsDBUnavailableError(nil).Times(1)
db.IsDBUnavailableError(nil)
client.EXPECT().IsDBUnavailableError(nil).Return(true).Times(1)
if db.IsDBUnavailableError(nil) != true {
t.Errorf("IsDBUnavailableError returned false but want true")
}

client.EXPECT().IsCassandraConsistencyError(nil).Times(1)
db.isCassandraConsistencyError(nil)
client.EXPECT().IsCassandraConsistencyError(nil).Return(true).Times(1)
if db.isCassandraConsistencyError(nil) != true {
t.Errorf("IsNotFoundError returned false but want true")
}

session.EXPECT().Close().Times(1)
db.Close()
Expand Down

0 comments on commit c6c27d4

Please sign in to comment.