Skip to content

Commit

Permalink
fix: error message
Browse files Browse the repository at this point in the history
  • Loading branch information
alexisvisco committed Oct 28, 2024
1 parent 9ebd289 commit 900377f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/schema/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func isTableDoesNotExists(err error) bool {
regexp.MustCompile(`Error 1146 \(42S02\): Table '.*' doesn't exist`),
regexp.MustCompile(`ERROR: relation ".*" does not exist \(SQLSTATE 42P01\)`),
regexp.MustCompile(`no such table: .*`),
regexp.MustCompile(`.*does not exist (SQLSTATE=42P01).*`),
regexp.MustCompile(`.*does not exist \(SQLSTATE=42P01\).*`),
}

for _, r := range re {
Expand Down
30 changes: 30 additions & 0 deletions pkg/schema/migrator_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package schema

import (
"errors"
"testing"
)

func Test_isTableDoesNotExists(t *testing.T) {
type args struct {
err error
}
tests := []struct {
name string
err error
want bool
}{
{
name: "bun driver",
err: errors.New("panic: error while fetching applied versions: ERROR: relation \"gwt.mig_schema_versions\" does not exist (SQLSTATE=42P01)\n"),
want: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := isTableDoesNotExists(tt.err); got != tt.want {
t.Errorf("isTableDoesNotExists() = %v, want %v", got, tt.want)
}
})
}
}

0 comments on commit 900377f

Please sign in to comment.