add tests for StreamTemplate.Reset()
@@ -59,3 +59,25 @@ func TestStreamTemplate_Delete(t *testing.T) {
t.Fatalf("expected [] got %q", names)
}
}
+
+func TestStreamTemplate_Reset(t *testing.T) {
+ srv, nc := startJSServer(t)
+ defer srv.Shutdown()
+
+ templ, err := jsch.NewStreamTemplate("orders_templ", 1, jsch.DefaultStream, jsch.Subjects("ORDERS.*"))
+ checkErr(t, err, "new stream template failed")
+
+ if len(templ.Streams()) != 0 {
+ t.Fatalf("expected no streams got %q", templ.Streams())
+ }
+
+ err = nc.Publish("ORDERS.1", []byte("hello"))
+ checkErr(t, err, "publish failed")
+
+ err = templ.Reset()
+ checkErr(t, err, "reset failed")
+
+ if len(templ.Streams()) != 1 || templ.Streams()[0] != "ORDERS_1" {
+ t.Fatalf("expected [ORDERS_1] got %q", templ.Streams())
+ }
+}
