Remove device DB from clientapi (#1352)

* Remove device DB from clientapi

* Remove device DB from startup configuration

It's all an impl detail now in user API
This commit is contained in:
Kegsay 2020-08-27 18:53:40 +01:00 committed by GitHub
parent c0f28845f8
commit 9af2f5f1f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 109 additions and 118 deletions

View file

@ -15,7 +15,6 @@ import (
"github.com/matrix-org/dendrite/userapi/api"
"github.com/matrix-org/dendrite/userapi/inthttp"
"github.com/matrix-org/dendrite/userapi/storage/accounts"
"github.com/matrix-org/dendrite/userapi/storage/devices"
"github.com/matrix-org/gomatrixserverlib"
)
@ -23,27 +22,31 @@ const (
serverName = gomatrixserverlib.ServerName("example.com")
)
func MustMakeInternalAPI(t *testing.T) (api.UserInternalAPI, accounts.Database, devices.Database) {
func MustMakeInternalAPI(t *testing.T) (api.UserInternalAPI, accounts.Database) {
accountDB, err := accounts.NewDatabase(&config.DatabaseOptions{
ConnectionString: "file::memory:",
}, serverName)
if err != nil {
t.Fatalf("failed to create account DB: %s", err)
}
deviceDB, err := devices.NewDatabase(&config.DatabaseOptions{
ConnectionString: "file::memory:",
}, serverName)
if err != nil {
t.Fatalf("failed to create device DB: %s", err)
cfg := &config.UserAPI{
DeviceDatabase: config.DatabaseOptions{
ConnectionString: "file::memory:",
MaxOpenConnections: 1,
MaxIdleConnections: 1,
},
Matrix: &config.Global{
ServerName: serverName,
},
}
return userapi.NewInternalAPI(accountDB, deviceDB, serverName, nil, nil), accountDB, deviceDB
return userapi.NewInternalAPI(accountDB, cfg, nil, nil), accountDB
}
func TestQueryProfile(t *testing.T) {
aliceAvatarURL := "mxc://example.com/alice"
aliceDisplayName := "Alice"
userAPI, accountDB, _ := MustMakeInternalAPI(t)
userAPI, accountDB := MustMakeInternalAPI(t)
_, err := accountDB.CreateAccount(context.TODO(), "alice", "foobar", "")
if err != nil {
t.Fatalf("failed to make account: %s", err)