Skip to content

Commit

Permalink
Merge pull request #58 from DenisCarriere/patch-3
Browse files Browse the repository at this point in the history
Add dsn test for blank password
  • Loading branch information
maoueh authored Apr 9, 2024
2 parents 8b81124 + 8244d7a commit 0977b68
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions db/dsn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,35 @@ func TestParseDSN(t *testing.T) {
expectError bool
expectConnString string
expectSchema string
expectPassword string
}{
{
name: "golden path",
dns: "psql://postgres:postgres@localhost/substreams-dev?enable_incremental_sort=off&sslmode=disable",
expectConnString: "host=localhost port=5432 user=postgres dbname=substreams-dev enable_incremental_sort=off sslmode=disable password=postgres",
expectSchema: "public",
expectPassword: "postgres",
},
{
name: "with schema",
dns: "psql://postgres:postgres@localhost/substreams-dev?enable_incremental_sort=off&sslmode=disable&schema=foo",
expectConnString: "host=localhost port=5432 user=postgres dbname=substreams-dev enable_incremental_sort=off sslmode=disable password=postgres",
expectSchema: "foo",
expectPassword: "postgres",
},
{
name: "with password",
dns: "clickhouse://default:password@localhost:9000/default",
expectConnString: "clickhouse://default:password@localhost:9000/default",
expectSchema: "default",
expectPassword: "password",
},
{
name: "with blank password",
dns: "clickhouse://default:@localhost:9000/default",
expectConnString: "clickhouse://default:@localhost:9000/default",
expectSchema: "default",
expectPassword: "",
},
}
for _, test := range tests {
Expand All @@ -37,6 +54,7 @@ func TestParseDSN(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, test.expectConnString, d.ConnString())
assert.Equal(t, test.expectSchema, d.schema)
assert.Equal(t, test.expectPassword, d.password)
}
})
}
Expand Down

0 comments on commit 0977b68

Please sign in to comment.