Skip to content

Commit 6a25a4f

Browse files
committed
fix: the database verify is not working
1 parent 0dab142 commit 6a25a4f

File tree

2 files changed

+18
-24
lines changed

2 files changed

+18
-24
lines changed

cmd/root.go

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,17 @@
11
/*
2-
*
3-
MIT License
2+
Copyright 2023-2024 API Testing Authors.
43
5-
Copyright (c) 2023 API Testing Authors.
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
67
7-
Permission is hereby granted, free of charge, to any person obtaining a copy
8-
of this software and associated documentation files (the "Software"), to deal
9-
in the Software without restriction, including without limitation the rights
10-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11-
copies of the Software, and to permit persons to whom the Software is
12-
furnished to do so, subject to the following conditions:
8+
http://www.apache.org/licenses/LICENSE-2.0
139
14-
The above copyright notice and this permission notice shall be included in all
15-
copies or substantial portions of the Software.
16-
17-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23-
SOFTWARE.
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
2415
*/
2516
package cmd
2617

pkg/server.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2023 API Testing Authors.
2+
Copyright 2023-2024 API Testing Authors.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -52,7 +52,10 @@ func createDB(user, password, address, database, driver string) (db *gorm.DB, er
5252
dialector = mysql.Open(dsn)
5353
case "postgres":
5454
obj := strings.Split(address, ":")
55-
host, port := obj[0], obj[1]
55+
host, port := obj[0], "5432"
56+
if len(obj) > 1 {
57+
port = obj[1]
58+
}
5659
dsn = fmt.Sprintf("host=%s user=%s password=%s dbname=%s port=%s sslmode=disable TimeZone=Asia/Shanghai", host, user, password, database, port)
5760
dialector = postgres.Open(dsn)
5861
default:
@@ -252,10 +255,10 @@ func (s *dbserver) DeleteTestCase(ctx context.Context, testcase *server.TestCase
252255
}
253256

254257
func (s *dbserver) Verify(ctx context.Context, in *server.Empty) (reply *server.ExtensionStatus, err error) {
255-
db, clientErr := s.getClient(ctx)
258+
_, vErr := s.ListTestSuite(ctx, in)
256259
reply = &server.ExtensionStatus{
257-
Ready: err == nil && db != nil,
258-
Message: util.OKOrErrorMessage(clientErr),
260+
Ready: vErr == nil,
261+
Message: util.OKOrErrorMessage(vErr),
259262
Version: version.GetVersion(),
260263
}
261264
return

0 commit comments

Comments
 (0)