Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions internal/dms/pkg/constant/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ func ParseDBType(s string) (DBType, error) {
return DBTypeDM, nil
case "GaussDB":
return DBTypeGaussDB, nil
case "openGauss", "OPENGAUSS", "opengauss":
return DBTypeOpenGauss, nil
case "GaussDB for MySQL":
return DBTypeGaussDBForMySQL, nil
case "HANA":
Expand Down Expand Up @@ -278,6 +280,7 @@ const (
DBTypeHive DBType = "Hive"
DBTypeDM DBType = "达梦(DM)"
DBTypeGaussDB DBType = "GaussDB"
DBTypeOpenGauss DBType = "openGauss"
DBTypeGaussDBForMySQL DBType = "GaussDB for MySQL"
DBTypeHANA DBType = "HANA"
DBTypePolarDBForMySQL DBType = "PolarDB For MySQL"
Expand Down
32 changes: 32 additions & 0 deletions internal/dms/pkg/constant/const_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,35 @@ func TestParseDBType(t *testing.T) {
})
}
}

func TestParseDBType_OpenGauss_EE(t *testing.T) {
cases := map[string]struct {
input string
want DBType
wantErr bool
}{
"openGauss literal": {input: "openGauss", want: DBTypeOpenGauss, wantErr: false},
"OPENGAUSS upper": {input: "OPENGAUSS", want: DBTypeOpenGauss, wantErr: false},
"opengauss lower": {input: "opengauss", want: DBTypeOpenGauss, wantErr: false},
"GaussDB regression": {input: "GaussDB", want: DBTypeGaussDB, wantErr: false},
"GaussDB for MySQL regression": {input: "GaussDB for MySQL", want: DBTypeGaussDBForMySQL, wantErr: false},
"Unknown returns explicit error": {input: "Unknown", want: DBType(""), wantErr: true},
}
for name, tc := range cases {
t.Run(name, func(t *testing.T) {
got, err := ParseDBType(tc.input)
if tc.wantErr {
if err == nil {
t.Fatalf("expected error for input %q, got nil", tc.input)
}
return
}
if err != nil {
t.Fatalf("unexpected error for input %q: %v", tc.input, err)
}
if got != tc.want {
t.Fatalf("ParseDBType(%q): got %q, want %q", tc.input, got, tc.want)
}
})
}
}