Update ConnectionManager to still allow component defined connections (#3154)

This commit is contained in:
Till 2023-07-21 08:34:01 +02:00 committed by GitHub
parent 9582827493
commit e216c2fbf0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 61 additions and 30 deletions

View file

@ -48,6 +48,22 @@ func TestConnectionManager(t *testing.T) {
if !reflect.DeepEqual(writer, writer2) {
t.Fatalf("expected database writer to be reused")
}
// This test does not work with Postgres, because we can't just simply append
// "x" or replace the database to use.
if dbType == test.DBTypePostgres {
return
}
// Test different connection string
dbProps = &config.DatabaseOptions{ConnectionString: config.DataSource(conStr + "x")}
db3, _, err := cm.Connection(dbProps)
if err != nil {
t.Fatal(err)
}
if reflect.DeepEqual(db, db3) {
t.Fatalf("expected different database connection")
}
})
})
@ -115,4 +131,10 @@ func TestConnectionManager(t *testing.T) {
if err == nil {
t.Fatal("expected an error but got none")
}
// empty connection string is not allowed
_, _, err = cm2.Connection(&config.DatabaseOptions{})
if err == nil {
t.Fatal("expected an error but got none")
}
}