mirror of
https://github.com/element-hq/dendrite.git
synced 2025-09-13 21:02:25 +03:00
Update ConnectionManager to still allow component defined connections (#3154)
This commit is contained in:
parent
9582827493
commit
e216c2fbf0
2 changed files with 61 additions and 30 deletions
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue