diff --git a/postgres_exporter_integration_test.go b/postgres_exporter_integration_test.go index 6dcfe710..63216d25 100644 --- a/postgres_exporter_integration_test.go +++ b/postgres_exporter_integration_test.go @@ -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) +} \ No newline at end of file