Skip to content

Commit

Permalink
chore: fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgerojas26 committed Oct 12, 2024
1 parent 1390fe7 commit 765cafc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions drivers/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ func (db *Postgres) GetTableColumns(database, table string) (results [][]string,
results = append(results, row)
}

if err := rows.Err(); err != nil {
return nil, err
}

return
}

Expand Down
9 changes: 7 additions & 2 deletions drivers/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ import (
"testing"

gomock "github.com/DATA-DOG/go-sqlmock"

"github.com/jorgerojas26/lazysql/models"
)

func Test_queriesInTransaction(t *testing.T) {
tests := []struct {
name string
queries []models.Query
setMockExpectations func(mock gomock.Sqlmock)
assertErr func(t *testing.T, err error)
name string
queries []models.Query
}{
{
name: "successful transaction",
Expand All @@ -38,6 +39,7 @@ func Test_queriesInTransaction(t *testing.T) {
mock.ExpectCommit().WillReturnError(errors.New("commit error"))
},
assertErr: func(t *testing.T, err error) {
t.Helper()
if !strings.Contains(err.Error(), "commit error") {
t.Errorf("expected error to contain 'commit error', got %v", err)
}
Expand All @@ -54,6 +56,7 @@ func Test_queriesInTransaction(t *testing.T) {
mock.ExpectRollback()
},
assertErr: func(t *testing.T, err error) {
t.Helper()
if !strings.Contains(err.Error(), "query error") {
t.Errorf("expected error to contain 'commit error', got %v", err)
}
Expand All @@ -73,6 +76,7 @@ func Test_queriesInTransaction(t *testing.T) {
mock.ExpectRollback()
},
assertErr: func(t *testing.T, err error) {
t.Helper()
if !strings.Contains(err.Error(), "query error") {
t.Errorf("expected error to contain 'commit error', got %v", err)
}
Expand All @@ -89,6 +93,7 @@ func Test_queriesInTransaction(t *testing.T) {
mock.ExpectRollback().WillReturnError(errors.New("rollback error"))
},
assertErr: func(t *testing.T, err error) {
t.Helper()
errMsg := err.Error()
if !strings.Contains(errMsg, "query error") {
t.Errorf("expected error to contain 'commit error', got %v", err)
Expand Down

0 comments on commit 765cafc

Please sign in to comment.