@@ -24,7 +24,20 @@ import (
2424)
2525
2626func testPostgres () * Postgres {
27- return & Postgres {"local" , test .GetPostgresHost (), test .GetPostgresPort (), "testdb" , "testuser" , "testpassword" , []string {}, false , false , false , []string {}}
27+ return & Postgres {
28+ Backend : "local" ,
29+ Host : test .GetPostgresHost (),
30+ Port : test .GetPostgresPort (),
31+ Database : "testdb" ,
32+ User : "testuser" ,
33+ Password : "testpassword" ,
34+ Monitoring : false ,
35+ Extensions : []string {},
36+ SSLEnabled : false ,
37+ SkipCAVerify : false ,
38+ DropPublicSchema : false ,
39+ Schemas : []string {},
40+ }
2841}
2942
3043func getPostgresAdmin () AdminCredentials {
@@ -78,21 +91,41 @@ func TestDropPublicSchemaFail(t *testing.T) {
7891 assert .Error (t , p .checkSchemas ())
7992}
8093
81- func TestDropPublicSchema (t * testing.T ) {
94+ func TestDropPublicSchemaMonitoringTrue (t * testing.T ) {
8295 p := testPostgres ()
8396 admin := getPostgresAdmin ()
97+ p .Monitoring = true
98+ p .DropPublicSchema = true
99+ p .dropPublicSchema (admin )
100+ assert .Error (t , p .checkSchemas ())
101+ }
102+
103+ func TestDropPublicSchemaMonitoringFalse (t * testing.T ) {
104+ p := testPostgres ()
105+ admin := getPostgresAdmin ()
106+ p .Monitoring = false
84107 p .DropPublicSchema = true
85108 p .dropPublicSchema (admin )
86109 assert .NoError (t , p .checkSchemas ())
87110
88- // Schemas is recreated here not to breaks tests for extensions
111+ // Schemas is recreated here not to breaks tests
89112 p .Schemas = []string {"public" }
90113 assert .NoError (t , p .createSchemas (admin ))
91114}
92115
116+ func TestEnableMonitoring (t * testing.T ) {
117+ p := testPostgres ()
118+ admin := getPostgresAdmin ()
119+ p .Monitoring = true
120+ p .enableMonitoring (admin )
121+ p .Extensions = []string {"pg_stat_statements" }
122+ assert .NoError (t , p .checkExtensions ())
123+ }
124+
93125func TestPostgresNoExtensions (t * testing.T ) {
94126 admin := getPostgresAdmin ()
95127 p := testPostgres ()
128+ p .Extensions = []string {}
96129
97130 assert .NoError (t , p .addExtensions (admin ))
98131 assert .NoError (t , p .checkExtensions ())
0 commit comments