forked from grafana/agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix parsePostgresURL issue (grafana#1111)
* Fix parsePostgresURL issue * Update Implementation and fix unit test * Add nolint and fix unit test * Update changelog * move changelog entry to unreleased Co-authored-by: Robert Fratto <[email protected]>
- Loading branch information
1 parent
014c9f3
commit 831b661
Showing
3 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
pkg/integrations/postgres_exporter/postgres_exporter_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package postgres_exporter //nolint:golint | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test_ParsePostgresURL(t *testing.T) { | ||
dsn := "postgresql://linus:42secret@localhost:5432/postgres?sslmode=disable" | ||
expected := map[string]string{ | ||
"dbname": "postgres", | ||
"host": "localhost", | ||
"password": "42secret", | ||
"port": "5432", | ||
"sslmode": "disable", | ||
"user": "linus", | ||
} | ||
|
||
actual, err := parsePostgresURL(dsn) | ||
require.NoError(t, err) | ||
require.Equal(t, actual, expected) | ||
|
||
} |