Fix tests

This commit is contained in:
Neil Alexander 2022-03-22 16:33:28 +00:00
parent 08b992b0bc
commit fec757e1d2
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -26,8 +26,8 @@ func Prepare(process *process.ProcessContext, cfg *config.JetStream) (natsclient
if natsServer == nil { if natsServer == nil {
var err error var err error
natsServer, err = natsserver.NewServer(&natsserver.Options{ natsServer, err = natsserver.NewServer(&natsserver.Options{
ServerName: "monolith", ServerName: "monolith",
//DontListen: true, DontListen: true,
JetStream: true, JetStream: true,
StoreDir: string(cfg.StoragePath), StoreDir: string(cfg.StoragePath),
NoSystemAccount: true, NoSystemAccount: true,
@ -81,12 +81,13 @@ func setupNATS(cfg *config.JetStream, nc *natsclient.Conn) (natsclient.JetStream
if err != nil && err != natsclient.ErrStreamNotFound { if err != nil && err != natsclient.ErrStreamNotFound {
logrus.WithError(err).Fatal("Unable to get stream info") logrus.WithError(err).Fatal("Unable to get stream info")
} }
if len(stream.Subjects) == 0 { subjects := stream.Subjects
stream.Subjects = []string{name, name + ".>"} if len(subjects) == 0 {
subjects = []string{name, name + ".>"}
} }
if info != nil { if info != nil {
switch { switch {
case !reflect.DeepEqual(info.Config.Subjects, stream.Subjects): case !reflect.DeepEqual(info.Config.Subjects, subjects):
fallthrough fallthrough
case info.Config.Retention != stream.Retention: case info.Config.Retention != stream.Retention:
fallthrough fallthrough
@ -108,8 +109,9 @@ func setupNATS(cfg *config.JetStream, nc *natsclient.Conn) (natsclient.JetStream
// array, otherwise we end up with namespaces on namespaces. // array, otherwise we end up with namespaces on namespaces.
namespaced := *stream namespaced := *stream
namespaced.Name = name namespaced.Name = name
namespaced.Subjects = subjects
if _, err = s.AddStream(&namespaced); err != nil { if _, err = s.AddStream(&namespaced); err != nil {
logrus.WithError(err).WithField("stream", name).Fatal("Unable to add stream") logrus.WithError(err).WithField("stream", name).WithField("subjects", subjects).Fatal("Unable to add stream")
} }
} }
} }