@@ -4,12 +4,13 @@ Copyright IBM Corp. All Rights Reserved.
44SPDX-License-Identifier: Apache-2.0
55*/
66
7- package postgres
7+ package postgres_test
88
99import (
1010 "context"
1111 "path/filepath"
1212
13+ "github.com/hyperledger/fabric-ca/lib/server/db/postgres"
1314 "github.com/hyperledger/fabric-ca/lib/server/db/postgres/mocks"
1415 "github.com/hyperledger/fabric-ca/lib/tls"
1516 . "github.com/onsi/ginkgo"
@@ -23,7 +24,7 @@ const (
2324
2425var _ = Describe ("Postgres" , func () {
2526 var (
26- db * Postgres
27+ db * postgres. Postgres
2728 mockDB * mocks.FabricCADB
2829 )
2930
@@ -32,7 +33,7 @@ var _ = Describe("Postgres", func() {
3233 Enabled : true ,
3334 CertFiles : []string {filepath .Join (testdataDir , "root.pem" )},
3435 }
35- db = NewDB (
36+ db = postgres . NewDB (
3637 "host=localhost port=5432 user=root password=rootpw dbname=fabric_ca" ,
3738 "" ,
3839 tls ,
@@ -43,7 +44,7 @@ var _ = Describe("Postgres", func() {
4344
4445 Context ("open connection to database" , func () {
4546 It ("fails to connect if the contains incorrect syntax" , func () {
46- db = NewDB (
47+ db = postgres . NewDB (
4748 "hos) (t=localhost port=5432 user=root password=rootpw dbname=fabric-ca" ,
4849 "" ,
4950 nil ,
@@ -53,7 +54,7 @@ var _ = Describe("Postgres", func() {
5354 Expect (err ).To (HaveOccurred ())
5455 Expect (err .Error ()).Should (Equal ("Database name 'fabric-ca' cannot contain any '-' or end with '.db'" ))
5556
56- db = NewDB (
57+ db = postgres . NewDB (
5758 "host=localhost port=5432 user=root password=rootpw dbname=fabric_ca.db" ,
5859 "" ,
5960 nil ,
@@ -148,12 +149,10 @@ var _ = Describe("Postgres", func() {
148149
149150 When ("the database already exists" , func () {
150151 It ("does not attempt to create the database" , func () {
151- mockDB .GetCalls (func (s string , i interface {}, s2 string , i2 ... interface {}) error {
152- exists := i .(* bool )
153- * exists = true
154- i = exists
152+ mockDB .GetStub = func (s string , i interface {}, s2 string , i2 ... interface {}) error {
153+ * (i .(* bool )) = true
155154 return nil
156- })
155+ }
157156 db .SqlxDB = mockDB
158157 sqlxDB , err := db .CreateDatabase ()
159158 Expect (err ).NotTo (HaveOccurred ())
0 commit comments