diff --git a/federationapi/federationapi_keys_test.go b/federationapi/federationapi_keys_test.go index b95039636..4774c8820 100644 --- a/federationapi/federationapi_keys_test.go +++ b/federationapi/federationapi_keys_test.go @@ -68,6 +68,13 @@ func TestMain(m *testing.M) { panic("can't create cache: " + err.Error()) } + // Create a temporary directory for JetStream. + d, err := ioutil.TempDir("./", "jetstream*") + if err != nil { + panic(err) + } + defer os.RemoveAll(d) + // Draw up just enough Dendrite config for the server key // API to work. cfg := &config.Dendrite{} @@ -75,6 +82,8 @@ func TestMain(m *testing.M) { cfg.Global.ServerName = gomatrixserverlib.ServerName(s.name) cfg.Global.PrivateKey = testPriv cfg.Global.JetStream.InMemory = true + cfg.Global.JetStream.TopicPrefix = string(s.name[:1]) + cfg.Global.JetStream.StoragePath = config.Path(d) cfg.Global.KeyID = serverKeyID cfg.Global.KeyValidityPeriod = s.validity cfg.FederationAPI.Database.ConnectionString = config.DataSource("file::memory:") diff --git a/setup/jetstream/nats.go b/setup/jetstream/nats.go index 5d8906601..6dbbd1f41 100644 --- a/setup/jetstream/nats.go +++ b/setup/jetstream/nats.go @@ -74,10 +74,7 @@ func setupNATS(cfg *config.JetStream, nc *natsclient.Conn) (nats.JetStreamContex logrus.WithError(err).Fatal("Unable to get stream info") } if info == nil { - // Define a default subject if not already specified. - if len(stream.Subjects) == 0 { - stream.Subjects = []string{name} - } + stream.Subjects = []string{name} // If we're trying to keep everything in memory (e.g. unit tests) // then overwrite the storage policy.