Add test case for issue #93.

This commit is contained in:
Will Rouesnel 2017-08-03 22:20:03 +10:00
parent a7ff84a674
commit 41cb2e7a68
1 changed files with 15 additions and 0 deletions

View File

@ -48,6 +48,7 @@ func (s *IntegrationSuite) TestAllNamespacesReturnResults(c *C) {
}
}()
// Open a database connection
db, err := sql.Open("postgres", s.e.dsn)
c.Assert(db, NotNil)
@ -73,3 +74,17 @@ func (s *IntegrationSuite) TestAllNamespacesReturnResults(c *C) {
}
}
}
// TestInvalidDsnDoesntCrash tests that specifying an invalid DSN doesn't crash the exporter.
// https://github.com/wrouesnel/postgres_exporter/issues/93
func (s *IntegrationSuite) TestInvalidDsnDoesntCrash(c *C) {
// Setup a dummy channel to consume metrics
ch := make(chan prometheus.Metric, 100)
go func() {
for range ch {
}
}()
exporter := NewExporter("an invalid dsn", *queriesPath)
exporter.scrape(ch)
}