Skip to content

Commit

Permalink
Fix errcheck in ./common/persistence/ (#3743)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSnowden committed Dec 21, 2022
1 parent 11b808a commit d896157
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
1 change: 1 addition & 0 deletions common/persistence/dataInterfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,7 @@ type (
}

// Closeable is an interface for any entity that supports a close operation to release resources
// TODO: allow this method to return errors
Closeable interface {
Close()
}
Expand Down
5 changes: 4 additions & 1 deletion common/persistence/sql/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ func (m *SqlStore) GetName() string {

func (m *SqlStore) Close() {
if m.Db != nil {
m.Db.Close()
err := m.Db.Close()
if err != nil {
m.logger.Error("Error closing SQL database", tag.Error(err))
}
}
}

Expand Down
21 changes: 16 additions & 5 deletions common/persistence/tests/sqlite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"path"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"

"go.temporal.io/server/common/config"
Expand Down Expand Up @@ -179,7 +180,9 @@ func TestSQLiteTaskQueueTaskSuite(t *testing.T) {
func TestSQLiteFileExecutionMutableStateStoreSuite(t *testing.T) {
cfg := NewSQLiteFileConfig()
SetupSQLiteDatabase(cfg)
defer os.Remove(cfg.DatabaseName)
defer func() {
assert.NoError(t, os.Remove(cfg.DatabaseName))
}()
logger := log.NewNoopLogger()
factory := sql.NewFactory(
*cfg,
Expand Down Expand Up @@ -212,7 +215,9 @@ func TestSQLiteFileExecutionMutableStateStoreSuite(t *testing.T) {
func TestSQLiteFileExecutionMutableStateTaskStoreSuite(t *testing.T) {
cfg := NewSQLiteFileConfig()
SetupSQLiteDatabase(cfg)
defer os.Remove(cfg.DatabaseName)
defer func() {
assert.NoError(t, os.Remove(cfg.DatabaseName))
}()
logger := log.NewNoopLogger()
factory := sql.NewFactory(
*cfg,
Expand Down Expand Up @@ -245,7 +250,9 @@ func TestSQLiteFileExecutionMutableStateTaskStoreSuite(t *testing.T) {
func TestSQLiteFileHistoryStoreSuite(t *testing.T) {
cfg := NewSQLiteFileConfig()
SetupSQLiteDatabase(cfg)
defer os.Remove(cfg.DatabaseName)
defer func() {
assert.NoError(t, os.Remove(cfg.DatabaseName))
}()
logger := log.NewNoopLogger()
factory := sql.NewFactory(
*cfg,
Expand All @@ -268,7 +275,9 @@ func TestSQLiteFileHistoryStoreSuite(t *testing.T) {
func TestSQLiteFileTaskQueueSuite(t *testing.T) {
cfg := NewSQLiteFileConfig()
SetupSQLiteDatabase(cfg)
defer os.Remove(cfg.DatabaseName)
defer func() {
assert.NoError(t, os.Remove(cfg.DatabaseName))
}()
logger := log.NewNoopLogger()
factory := sql.NewFactory(
*cfg,
Expand All @@ -291,7 +300,9 @@ func TestSQLiteFileTaskQueueSuite(t *testing.T) {
func TestSQLiteFileTaskQueueTaskSuite(t *testing.T) {
cfg := NewSQLiteFileConfig()
SetupSQLiteDatabase(cfg)
defer os.Remove(cfg.DatabaseName)
defer func() {
assert.NoError(t, os.Remove(cfg.DatabaseName))
}()
logger := log.NewNoopLogger()
factory := sql.NewFactory(
*cfg,
Expand Down

0 comments on commit d896157

Please sign in to comment.