aboutsummaryrefslogtreecommitdiff
path: root/currentstateserver/currentstateserver_test.go
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2020-08-10 14:18:04 +0100
committerGitHub <noreply@github.com>2020-08-10 14:18:04 +0100
commit4b09f445c992fd0a389efc34d75aaa7e5bd50e9c (patch)
tree18d6168718ac06e569eb271f25ed4dc064010b50 /currentstateserver/currentstateserver_test.go
parentfdabba1851c489d801ea4029bce9dec7d415b2df (diff)
Configuration format v1 (#1230)
* Initial pass at refactoring config (not finished) * Don't forget current state and EDU servers * More shifting around * Update server key API tests * Fix roomserver test * Fix more tests * Further tweaks * Fix current state server test (sort of) * Maybe fix appservices * Fix client API test * Include database connection string in database options * Fix sync API build * Update config test * Fix unit tests * Fix federation sender build * Fix gobind build * Set Listen address for all services in HTTP monolith mode * Validate config, reinstate appservice derived in directory, tweaks * Tweak federation API test * Set MaxOpenConnections/MaxIdleConnections to previous values * Update generate-config
Diffstat (limited to 'currentstateserver/currentstateserver_test.go')
-rw-r--r--currentstateserver/currentstateserver_test.go22
1 files changed, 16 insertions, 6 deletions
diff --git a/currentstateserver/currentstateserver_test.go b/currentstateserver/currentstateserver_test.go
index 19317390..2b0e40c2 100644
--- a/currentstateserver/currentstateserver_test.go
+++ b/currentstateserver/currentstateserver_test.go
@@ -15,6 +15,7 @@
package currentstateserver
import (
+ "bytes"
"context"
"crypto/ed25519"
"encoding/json"
@@ -94,11 +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.Kafka.Topics.OutputRoomEvent = config.Topic(kafkaTopic)
- cfg.Database.CurrentState = config.DataSource("file:" + stateDBName)
- db, err := sqlutil.Open(sqlutil.SQLiteDriverName(), "file:"+naffkaDBName, nil)
+ 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(&config.DatabaseOptions{
+ ConnectionString: config.DataSource("file:" + naffkaDBName),
+ })
if err != nil {
t.Fatalf("Failed to open naffka database: %s", err)
}
@@ -110,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)
}
@@ -165,8 +170,13 @@ func TestQueryCurrentState(t *testing.T) {
t.Errorf("QueryCurrentState want tuple %+v but it is missing from the response", tuple)
continue
}
- if !reflect.DeepEqual(gotEvent.JSON(), wantEvent.JSON()) {
- t.Errorf("QueryCurrentState tuple %+v got event JSON %s want %s", tuple, string(gotEvent.JSON()), string(wantEvent.JSON()))
+ gotCanon, err := gomatrixserverlib.CanonicalJSON(gotEvent.JSON())
+ if err != nil {
+ t.Errorf("CanonicalJSON failed: %w", err)
+ continue
+ }
+ if !bytes.Equal(gotCanon, wantEvent.JSON()) {
+ t.Errorf("QueryCurrentState tuple %+v got event JSON %s want %s", tuple, string(gotCanon), string(wantEvent.JSON()))
}
}
}