aboutsummaryrefslogtreecommitdiff
path: root/setup/jetstream
diff options
context:
space:
mode:
authorkegsay <kegan@matrix.org>2022-04-08 10:12:30 +0100
committerGitHub <noreply@github.com>2022-04-08 10:12:30 +0100
commit7499147550110d24fa3a376bd811d9dd38971629 (patch)
tree335f11802f6cd391effddae9709b014ed1a17c58 /setup/jetstream
parent955e6eb307c78594fe9614f6a304dc521ba28d49 (diff)
Add test infrastructure code for dendrite unit/integ tests (#2331)
* Add test infrastructure code for dendrite unit/integ tests Start re-enabling some syncapi storage tests in the process. * Linting * Add postgres service to unit tests * dendrite not syncv3 * Skip test which doesn't work * Linting * Add `jetstream.PrepareForTests` Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
Diffstat (limited to 'setup/jetstream')
-rw-r--r--setup/jetstream/nats.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/setup/jetstream/nats.go b/setup/jetstream/nats.go
index 4e4fe7a2..1c8a89e8 100644
--- a/setup/jetstream/nats.go
+++ b/setup/jetstream/nats.go
@@ -13,12 +13,22 @@ import (
"github.com/sirupsen/logrus"
natsserver "github.com/nats-io/nats-server/v2/server"
+ "github.com/nats-io/nats.go"
natsclient "github.com/nats-io/nats.go"
)
var natsServer *natsserver.Server
var natsServerMutex sync.Mutex
+func PrepareForTests() (*process.ProcessContext, nats.JetStreamContext, *nats.Conn) {
+ cfg := &config.Dendrite{}
+ cfg.Defaults(true)
+ cfg.Global.JetStream.InMemory = true
+ pc := process.NewProcessContext()
+ js, jc := Prepare(pc, &cfg.Global.JetStream)
+ return pc, js, jc
+}
+
func Prepare(process *process.ProcessContext, cfg *config.JetStream) (natsclient.JetStreamContext, *natsclient.Conn) {
// check if we need an in-process NATS Server
if len(cfg.Addresses) != 0 {