mirror of
https://github.com/prometheus-community/postgres_exporter
synced 2025-04-22 23:15:26 +00:00
basic integration test
Signed-off-by: Paul van der Linden <mail@paultjuh.org>
This commit is contained in:
parent
ffa6782e41
commit
bc97291103
11
README.md
11
README.md
@ -285,3 +285,14 @@ GRANT SELECT ON postgres_exporter.pg_stat_statements TO postgres_exporter;
|
|||||||
> ```
|
> ```
|
||||||
> DATA_SOURCE_NAME=postgresql://postgres_exporter:password@localhost:5432/postgres?sslmode=disable
|
> DATA_SOURCE_NAME=postgresql://postgres_exporter:password@localhost:5432/postgres?sslmode=disable
|
||||||
> ```
|
> ```
|
||||||
|
|
||||||
|
|
||||||
|
## Running the tests
|
||||||
|
```
|
||||||
|
# Run the unit tests
|
||||||
|
make test
|
||||||
|
# Start the test database with docker
|
||||||
|
docker run -p 5432:5432 -e POSTGRES_DB=circle_test -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=test -d postgres
|
||||||
|
# Run the integration tests
|
||||||
|
DATA_SOURCE_NAME='postgresql://postgres:test@localhost:5432/circle_test?sslmode=disable' GOOPTS='-v -tags integration' make test
|
||||||
|
```
|
||||||
|
@ -162,3 +162,16 @@ func (s *IntegrationSuite) TestExtendQueriesDoesntCrash(c *C) {
|
|||||||
// scrape the exporter and make sure it works
|
// scrape the exporter and make sure it works
|
||||||
exporter.scrape(ch)
|
exporter.scrape(ch)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *IntegrationSuite) TestAutoDiscoverDatabases(c *C) {
|
||||||
|
dsn := os.Getenv("DATA_SOURCE_NAME")
|
||||||
|
|
||||||
|
exporter := NewExporter(
|
||||||
|
strings.Split(dsn, ","),
|
||||||
|
)
|
||||||
|
c.Assert(exporter, NotNil)
|
||||||
|
|
||||||
|
dsns := exporter.discoverDatabaseDSNs()
|
||||||
|
|
||||||
|
c.Assert(len(dsns), Equals, 2)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user