Skip to content

Commit b2557c4

Browse files
committed
do not panic when envs are set incorrectly - fix tests
1 parent 4f1e8f5 commit b2557c4

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

cmd/postgres_exporter/postgres_exporter_test.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ func (s *FunctionalSuite) TestEnvironmentSettingWithSecretsFiles(c *C) {
111111

112112
var expected = "postgresql://custom_username$&+,%2F%3A;=%3F%40:custom_password$&+,%2F%3A;=%3F%40@localhost:5432/?sslmode=disable"
113113

114-
dsn := getDataSources()
114+
dsn, err := getDataSources()
115+
if err != nil {
116+
c.Errorf("Unexpected error reading datasources")
117+
}
118+
115119
if len(dsn) == 0 {
116120
c.Errorf("Expected one data source, zero found")
117121
}
@@ -127,7 +131,11 @@ func (s *FunctionalSuite) TestEnvironmentSettingWithDns(c *C) {
127131
c.Assert(err, IsNil)
128132
defer UnsetEnvironment(c, "DATA_SOURCE_NAME")
129133

130-
dsn := getDataSources()
134+
dsn, err := getDataSources()
135+
if err != nil {
136+
c.Errorf("Unexpected error reading datasources")
137+
}
138+
131139
if len(dsn) == 0 {
132140
c.Errorf("Expected one data source, zero found")
133141
}
@@ -151,7 +159,11 @@ func (s *FunctionalSuite) TestEnvironmentSettingWithDnsAndSecrets(c *C) {
151159
c.Assert(err, IsNil)
152160
defer UnsetEnvironment(c, "DATA_SOURCE_PASS")
153161

154-
dsn := getDataSources()
162+
dsn, err := getDataSources()
163+
if err != nil {
164+
c.Errorf("Unexpected error reading datasources")
165+
}
166+
155167
if len(dsn) == 0 {
156168
c.Errorf("Expected one data source, zero found")
157169
}

0 commit comments

Comments
 (0)