@@ -18,12 +18,12 @@ import (
18
18
"go.mongodb.org/mongo-driver/bson"
19
19
)
20
20
21
- func Test_MongoDBRetriever_Retrieve (t * testing.T ) {
21
+ func Test_PostgreSQLRetriever_Retrieve (t * testing.T ) {
22
22
ctx := context .Background ()
23
23
24
- dbName := "users "
25
- dbUser := "user "
26
- dbPassword := "password "
24
+ dbName := "flags_db "
25
+ dbUser := "root "
26
+ dbPassword := "example "
27
27
28
28
tests := []struct {
29
29
name string
@@ -56,7 +56,7 @@ func Test_MongoDBRetriever_Retrieve(t *testing.T) {
56
56
},
57
57
}
58
58
59
- // Start the postgres ctr and run any migrations on it
59
+ // Start the postgres container
60
60
ctr , err := postgres .Run (
61
61
ctx ,
62
62
"postgres:16-alpine" ,
@@ -69,10 +69,11 @@ func Test_MongoDBRetriever_Retrieve(t *testing.T) {
69
69
testcontainers .CleanupContainer (t , ctr )
70
70
require .NoError (t , err )
71
71
72
+ // Run initialization query to create the table and the column
72
73
_ , _ , err = ctr .Exec (ctx , []string {"psql" , "-U" , dbUser , "-d" , dbName , "-c" , "CREATE TABLE flags (id SERIAL PRIMARY KEY,flag JSONB)" })
73
74
require .NoError (t , err )
74
75
75
- //Create snapshot of the database, which is then restored before each test
76
+ // Create snapshot of the database, which is then restored before each test
76
77
err = ctr .Snapshot (ctx )
77
78
require .NoError (t , err )
78
79
@@ -89,7 +90,7 @@ func Test_MongoDBRetriever_Retrieve(t *testing.T) {
89
90
defer conn .Close (context .Background ())
90
91
91
92
if item .data != "" {
92
- // insert data
93
+ // Insert data
93
94
var documents []bson.M
94
95
err = json .Unmarshal ([]byte (item .data ), & documents )
95
96
require .NoError (t , err )
@@ -100,7 +101,7 @@ func Test_MongoDBRetriever_Retrieve(t *testing.T) {
100
101
}
101
102
}
102
103
103
- // retriever
104
+ // Initialize Retriever
104
105
mdb := postgresqlretriever.Retriever {
105
106
URI : dbURL ,
106
107
Table : "flags" ,
@@ -123,7 +124,6 @@ func Test_MongoDBRetriever_Retrieve(t *testing.T) {
123
124
}
124
125
125
126
require .NoError (t , err )
126
-
127
127
}
128
128
}
129
129
0 commit comments