diff --git a/ops_test.go b/ops_test.go
index c89eb76..b3879ee 100644
--- a/ops_test.go
+++ b/ops_test.go
@@ -539,14 +539,9 @@ func TestCancelCommit(t *testing.T) {
}
func TestCreateSubscription(t *testing.T) {
- st, err := time.Parse(time.RFC3339, "2023-06-07T18:31:48+02:00")
- if err != nil {
- t.Fatalf("invalid startTime: %s", st)
- }
- et, err := time.Parse(time.RFC3339, "2023-06-07T18:33:48+02:00")
- if err != nil {
- t.Fatalf("invalid endTime: %s", et)
- }
+ start := time.Date(2023, time.June, 07, 18, 31, 48, 00, time.UTC)
+ end := time.Date(2023, time.June, 07, 18, 33, 48, 00, time.UTC)
+
tt := []struct {
name string
options []CreateSubscriptionOption
@@ -555,28 +550,28 @@ func TestCreateSubscription(t *testing.T) {
{
name: "noOptions",
matches: []*regexp.Regexp{
- regexp.MustCompile(``),
+ regexp.MustCompile(``),
},
},
{
name: "startTime option",
- options: []CreateSubscriptionOption{WithStartTimeOption(st)},
+ options: []CreateSubscriptionOption{WithStartTimeOption(start)},
matches: []*regexp.Regexp{
- regexp.MustCompile(`` + regexp.QuoteMeta(st.Format(time.RFC3339)) + ``),
+ regexp.MustCompile(`` + regexp.QuoteMeta(start.Format(time.RFC3339)) + ``),
},
},
{
name: "endTime option",
- options: []CreateSubscriptionOption{WithEndTimeOption(et)},
+ options: []CreateSubscriptionOption{WithEndTimeOption(end)},
matches: []*regexp.Regexp{
- regexp.MustCompile(`` + regexp.QuoteMeta(et.Format(time.RFC3339)) + ``),
+ regexp.MustCompile(`` + regexp.QuoteMeta(end.Format(time.RFC3339)) + ``),
},
},
{
name: "stream option",
options: []CreateSubscriptionOption{WithStreamOption("thestream")},
matches: []*regexp.Regexp{
- regexp.MustCompile(`thestream`),
+ regexp.MustCompile(`thestream`),
},
},
}
@@ -590,19 +585,13 @@ func TestCreateSubscription(t *testing.T) {
ts.queueRespString(``)
err := sess.CreateSubscription(context.Background(), tc.options...)
- if err != nil {
- t.Errorf("unexpected error: %v", err)
- }
+ assert.NoError(t, err)
sentMsg, err := ts.popReq()
- if err != nil {
- t.Errorf("failed to read message sent to sever: %v", err)
- }
+ assert.NoError(t, err)
for _, match := range tc.matches {
- if !match.Match(sentMsg) {
- t.Errorf("sent message didn't match `%s`", match.String())
- }
+ assert.Regexp(t, match, string(sentMsg))
}
})
}