|
1 | 1 | /*
|
2 |
| -Copyright 2023-2024 API Testing Authors. |
| 2 | +Copyright 2023-2025 API Testing Authors. |
3 | 3 |
|
4 | 4 | Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | you may not use this file except in compliance with the License.
|
@@ -55,6 +55,9 @@ func createDB(user, password, address, database, driver string) (db *gorm.DB, er
|
55 | 55 | var dsn string
|
56 | 56 | switch driver {
|
57 | 57 | case "mysql", "":
|
| 58 | + if !strings.Contains(address, ":") { |
| 59 | + address = fmt.Sprintf("%s:%d", address, 3306) |
| 60 | + } |
58 | 61 | dsn = fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true", user, password, address, database)
|
59 | 62 | dialector = mysql.Open(dsn)
|
60 | 63 | case "sqlite":
|
@@ -93,8 +96,8 @@ func createDB(user, password, address, database, driver string) (db *gorm.DB, er
|
93 | 96 | return
|
94 | 97 | }
|
95 | 98 |
|
96 |
| -var dbCache map[string]*gorm.DB = make(map[string]*gorm.DB) |
97 |
| -var dbNameCache map[string]string = make(map[string]string) |
| 99 | +var dbCache = make(map[string]*gorm.DB) |
| 100 | +var dbNameCache = make(map[string]string) |
98 | 101 |
|
99 | 102 | func (s *dbserver) getClientWithDatabase(ctx context.Context, dbName string) (db *gorm.DB, err error) {
|
100 | 103 | store := remote.GetStoreFromContext(ctx)
|
@@ -191,19 +194,6 @@ func (s *dbserver) GetTestSuite(ctx context.Context, suite *remote.TestSuite) (r
|
191 | 194 | return
|
192 | 195 | }
|
193 | 196 |
|
194 |
| -func (s *dbserver) GetHistoryTestSuite(ctx context.Context, suite *remote.HistoryTestSuite) (reply *remote.HistoryTestSuite, err error) { |
195 |
| - query := &HistoryTestResult{} |
196 |
| - var db *gorm.DB |
197 |
| - if db, err = s.getClient(ctx); err != nil { |
198 |
| - return |
199 |
| - } |
200 |
| - |
201 |
| - if err = db.Find(&query, nameQuery, suite.HistorySuiteName).Error; err == nil { |
202 |
| - reply = ConvertToGRPCHistoryTestSuite(query) |
203 |
| - } |
204 |
| - return |
205 |
| -} |
206 |
| - |
207 | 197 | func (s *dbserver) UpdateTestSuite(ctx context.Context, suite *remote.TestSuite) (reply *remote.TestSuite, err error) {
|
208 | 198 | reply = &remote.TestSuite{}
|
209 | 199 | input := ConvertToDBTestSuite(suite)
|
|
0 commit comments