Skip to content
Merged
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
7 changes: 7 additions & 0 deletions internal/dms/pkg/constant/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,13 @@ var supportedDataExportDBTypes = map[DBType]struct{}{
DBTypeOceanBaseMySQL: {},
DBTypeHive: {},
DBTypeDM: {},
// 新增数据源 (Issue #593)
DBTypeTiDB: {},
DBTypeTDSQLForInnoDB: {},
DBTypeGoldenDB: {},
DBTypeTBase: {},
DBTypeGaussDB: {},
DBTypeDB2: {},
}

func CheckDBTypeIfDataExportSupported(dbtype string) bool {
Expand Down
64 changes: 64 additions & 0 deletions internal/dms/pkg/constant/const_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package constant

import (
"testing"
)

func TestCheckDBTypeIfDataExportSupported_NewTypes(t *testing.T) {
// 验证新增的数据源应在白名单中
newTypes := map[string]bool{
"TiDB": true,
"TDSQL For InnoDB": true,
"GoldenDB": true,
"TBase": true,
"GaussDB for MySQL": true, // GaussDB/openGauss: ParseDBType 的输入值是 "GaussDB for MySQL"
"DB2": true,
}
for dbType, expectedSupported := range newTypes {
t.Run(dbType, func(t *testing.T) {
got := CheckDBTypeIfDataExportSupported(dbType)
if got != expectedSupported {
t.Errorf("CheckDBTypeIfDataExportSupported(%q) = %v, want %v", dbType, got, expectedSupported)
}
})
}
}

func TestCheckDBTypeIfDataExportSupported_ExistingTypes(t *testing.T) {
// 回归测试: 验证已有的 7 种数据源仍在白名单中
existingTypes := map[string]bool{
"MySQL": true,
"PostgreSQL": true,
"Oracle": true,
"SQL Server": true,
"OceanBase For MySQL": true,
"Hive": true,
"DM": true,
}
for dbType, expectedSupported := range existingTypes {
t.Run(dbType, func(t *testing.T) {
got := CheckDBTypeIfDataExportSupported(dbType)
if got != expectedSupported {
t.Errorf("CheckDBTypeIfDataExportSupported(%q) = %v, want %v", dbType, got, expectedSupported)
}
})
}
}

func TestCheckDBTypeIfDataExportSupported_UnsupportedTypes(t *testing.T) {
// 验证未支持的类型返回 false
unsupportedTypes := map[string]bool{
"MongoDB": false,
"Redis": false,
"UnknownDB": false,
"": false,
}
for dbType, expectedSupported := range unsupportedTypes {
t.Run(dbType, func(t *testing.T) {
got := CheckDBTypeIfDataExportSupported(dbType)
if got != expectedSupported {
t.Errorf("CheckDBTypeIfDataExportSupported(%q) = %v, want %v", dbType, got, expectedSupported)
}
})
}
}