mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-20 21:33:19 -06:00
Fix unit tests
This commit is contained in:
parent
cc1d01cd28
commit
47a1ae2c33
|
|
@ -91,14 +91,14 @@ func (m *DendriteMonolith) Start() {
|
|||
cfg.Global.Kafka.Topics.OutputClientData = "clientapiOutput"
|
||||
cfg.Global.Kafka.Topics.OutputTypingEvent = "typingServerOutput"
|
||||
cfg.Global.Kafka.Topics.OutputSendToDeviceEvent = "sendToDeviceOutput"
|
||||
cfg.Global.Kafka.Database = config.DataSource(fmt.Sprintf("file:%s/dendrite-naffka.db", m.StorageDirectory))
|
||||
cfg.Global.Kafka.Database.ConnectionString = config.DataSource(fmt.Sprintf("file:%s/dendrite-naffka.db", m.StorageDirectory))
|
||||
cfg.UserAPI.AccountDatabase.ConnectionString = config.DataSource(fmt.Sprintf("file:%s/dendrite-account.db", m.StorageDirectory))
|
||||
cfg.UserAPI.DeviceDatabase.ConnectionString = config.DataSource(fmt.Sprintf("file:%s/dendrite-device.db", m.StorageDirectory))
|
||||
cfg.MediaAPI.Database.ConnectionString = config.DataSource(fmt.Sprintf("file:%s/dendrite-mediaapi.db", m.StorageDirectory))
|
||||
cfg.SyncAPI.Database.ConnectionString = config.DataSource(fmt.Sprintf("file:%s/dendrite-syncapi.db", m.StorageDirectory))
|
||||
cfg.RoomServer.Database.ConnectionString = config.DataSource(fmt.Sprintf("file:%s/dendrite-roomserver.db", m.StorageDirectory))
|
||||
cfg.ServerKeyAPI.Database.ConnectionString = config.DataSource(fmt.Sprintf("file:%s/dendrite-serverkey.db", m.StorageDirectory))
|
||||
cfg.KeyServer.Database.ConnectionString = config.DataSource(fmt.Sprintf("file:%s-e2ekey.db", *instanceName))
|
||||
cfg.KeyServer.Database.ConnectionString = config.DataSource(fmt.Sprintf("file:%s/dendrite-e2ekey.db", m.StorageDirectory))
|
||||
cfg.FederationSender.Database.ConnectionString = config.DataSource(fmt.Sprintf("file:%s/dendrite-federationsender.db", m.StorageDirectory))
|
||||
cfg.AppServiceAPI.Database.ConnectionString = config.DataSource(fmt.Sprintf("file:%s/dendrite-appservice.db", m.StorageDirectory))
|
||||
cfg.CurrentStateServer.Database.ConnectionString = config.DataSource(fmt.Sprintf("file:%s/dendrite-currentstate.db", m.StorageDirectory))
|
||||
|
|
@ -118,7 +118,7 @@ func (m *DendriteMonolith) Start() {
|
|||
|
||||
serverKeyAPI := &signing.YggdrasilKeys{}
|
||||
keyRing := serverKeyAPI.KeyRing()
|
||||
keyAPI := keyserver.NewInternalAPI(base.Cfg, federation, base.KafkaProducer)
|
||||
keyAPI := keyserver.NewInternalAPI(&base.Cfg.KeyServer, federation, base.KafkaProducer)
|
||||
userAPI := userapi.NewInternalAPI(accountDB, deviceDB, cfg.Global.ServerName, cfg.Derived.ApplicationServices, keyAPI)
|
||||
keyAPI.SetUserAPI(userAPI)
|
||||
|
||||
|
|
@ -158,11 +158,7 @@ func (m *DendriteMonolith) Start() {
|
|||
RoomserverAPI: rsAPI,
|
||||
UserAPI: userAPI,
|
||||
StateAPI: stateAPI,
|
||||
<<<<<<< HEAD
|
||||
KeyAPI: keyserver.NewInternalAPI(&base.Cfg.KeyServer, federation, userAPI, base.KafkaProducer),
|
||||
=======
|
||||
KeyAPI: keyAPI,
|
||||
>>>>>>> master
|
||||
ExtPublicRoomsProvider: yggrooms.NewYggdrasilRoomProvider(
|
||||
ygg, fsAPI, federation,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -95,12 +95,15 @@ func MustWriteOutputEvent(t *testing.T, producer sarama.SyncProducer, out *rooms
|
|||
|
||||
func MustMakeInternalAPI(t *testing.T) (api.CurrentStateInternalAPI, sarama.SyncProducer, func()) {
|
||||
cfg := &config.Dendrite{}
|
||||
cfg.Defaults()
|
||||
stateDBName := "test_state.db"
|
||||
naffkaDBName := "test_naffka.db"
|
||||
cfg.Global.ServerName = "kaer.morhen"
|
||||
cfg.Global.Kafka.Topics.OutputRoomEvent = config.Topic(kafkaTopic)
|
||||
cfg.CurrentStateServer.Database.ConnectionString = config.DataSource("file:" + stateDBName)
|
||||
db, err := sqlutil.Open(sqlutil.SQLiteDriverName(), "file:"+naffkaDBName, nil)
|
||||
db, err := sqlutil.Open(&config.DatabaseOptions{
|
||||
ConnectionString: config.DataSource("file:" + naffkaDBName),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to open naffka database: %s", err)
|
||||
}
|
||||
|
|
@ -112,7 +115,7 @@ func MustMakeInternalAPI(t *testing.T) (api.CurrentStateInternalAPI, sarama.Sync
|
|||
if err != nil {
|
||||
t.Fatalf("Failed to create naffka consumer: %s", err)
|
||||
}
|
||||
return NewInternalAPI(cfg, naff), naff, func() {
|
||||
return NewInternalAPI(&cfg.CurrentStateServer, naff), naff, func() {
|
||||
os.Remove(naffkaDBName)
|
||||
os.Remove(stateDBName)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ func TestRoomsV3URLEscapeDoNot404(t *testing.T) {
|
|||
cfg.Global.ServerName = gomatrixserverlib.ServerName("localhost")
|
||||
cfg.Global.PrivateKey = privKey
|
||||
cfg.Global.Kafka.UseNaffka = true
|
||||
cfg.Global.Kafka.Database = "file::memory:"
|
||||
cfg.Global.Kafka.Database.ConnectionString = config.DataSource("file::memory:")
|
||||
cfg.FederationSender.Database.ConnectionString = config.DataSource("file::memory:")
|
||||
base := setup.NewBaseDendrite(cfg, "Test", false)
|
||||
keyRing := &test.NopJSONVerifier{}
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ func loadAppServices(config *AppServiceAPI, derived *Derived) error {
|
|||
// setupRegexps will create regex objects for exclusive and non-exclusive
|
||||
// usernames, aliases and rooms of all application services, so that other
|
||||
// methods can quickly check if a particular string matches any of them.
|
||||
func setupRegexps(cfg *AppServiceAPI, derived *Derived) (err error) {
|
||||
func setupRegexps(_ *AppServiceAPI, derived *Derived) (err error) {
|
||||
// Combine all exclusive namespaces for later string checking
|
||||
var exclusiveUsernameStrings, exclusiveAliasStrings []string
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ const testConfig = `
|
|||
version: 1
|
||||
global:
|
||||
server_name: localhost
|
||||
private_key: matrix.pem
|
||||
private_key: matrix_key.pem
|
||||
key_validity_period: 168h0m0s
|
||||
trusted_third_party_id_servers: []
|
||||
kafka:
|
||||
|
|
|
|||
|
|
@ -65,7 +65,9 @@ func TestKeyChangesNoDupes(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestKeyChangesUpperLimit(t *testing.T) {
|
||||
db, err := NewDatabase("file::memory:", nil)
|
||||
db, err := NewDatabase(&config.DatabaseOptions{
|
||||
ConnectionString: "file::memory:",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to NewDatabase: %s", err)
|
||||
}
|
||||
|
|
@ -87,7 +89,9 @@ func TestKeyChangesUpperLimit(t *testing.T) {
|
|||
// The purpose of this test is to make sure that the storage layer is generating sequential stream IDs per user,
|
||||
// and that they are returned correctly when querying for device keys.
|
||||
func TestDeviceKeysStreamIDGeneration(t *testing.T) {
|
||||
db, err := NewDatabase("file::memory:", nil)
|
||||
db, err := NewDatabase(&config.DatabaseOptions{
|
||||
ConnectionString: "file::memory:",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to NewDatabase: %s", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue