Skip to content

Commit 2684ff7

Browse files
committed
Expanding test
Signed-off-by: Edward Payzant <adam@synadia.com>
1 parent 53da82c commit 2684ff7

1 file changed

Lines changed: 33 additions & 3 deletions

File tree

test/test.c

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27279,7 +27279,8 @@ void test_JetStreamPublishSchedule(void)
2727927279
jsPubOptions opts;
2728027280
jsErrCode jerr = 0;
2728127281
natsSubscription *sub = NULL;
27282-
natsMsg *msg = NULL;
27282+
natsMsg *msg = NULL;
27283+
const char *hvalue = NULL;
2728327284

2728427285
JS_SETUP(2, 14, 0);
2728527286

@@ -27289,10 +27290,11 @@ void test_JetStreamPublishSchedule(void)
2728927290

2729027291
test("Add stream: ");
2729127292
cfg.Name = "TEST";
27292-
cfg.Subjects = (const char*[3]){"schedules", "real", "stop"};
27293-
cfg.SubjectsLen = 3;
27293+
cfg.Subjects = (const char*[5]){"schedules", "real", "stop", "src", "sched2"};
27294+
cfg.SubjectsLen = 5;
2729427295
cfg.AllowMsgTTL = true;
2729527296
cfg.AllowMsgSchedules = true;
27297+
cfg.AllowRollup = true;
2729627298

2729727299
s = js_AddStream(NULL, js, &cfg, NULL, NULL);
2729827300
testCond(s == NATS_OK);
@@ -27372,6 +27374,34 @@ void test_JetStreamPublishSchedule(void)
2737227374
testCond(s == NATS_TIMEOUT);
2737327375
nats_clearLastError();
2737427376

27377+
test("Publish source message: ");
27378+
s = js_Publish(NULL, js, "src", "from-source", 11, NULL, &jerr);
27379+
testCond((s == NATS_OK) && (jerr == 0));
27380+
27381+
test("Schedule publish with Source, TimeZone, Rollup: ");
27382+
jsPubOptions_Init(&opts);
27383+
opts.Schedule.Schedule = "* * * * * *";
27384+
opts.Schedule.Target = "real";
27385+
opts.Schedule.Source = "src";
27386+
opts.Schedule.TimeZone = "UTC";
27387+
opts.Schedule.Rollup = true;
27388+
s = js_Publish(NULL, js, "sched2", "fallback", 8, &opts, &jerr);
27389+
testCond((s == NATS_OK) && (jerr == 0));
27390+
27391+
test("Receive message published from Source: ");
27392+
s = natsSubscription_NextMsg(&msg, sub, 2000);
27393+
testCond((s == NATS_OK) && (msg != NULL)
27394+
&& (strcmp(natsMsg_GetSubject(msg), "real") == 0)
27395+
&& (strcmp(natsMsg_GetData(msg), "from-source") == 0));
27396+
natsMsg_Destroy(msg);
27397+
msg = NULL;
27398+
27399+
test("Cancel sched2: ");
27400+
jsPubOptions_Init(&opts);
27401+
opts.Schedule.CancelScheduledSubject = "sched2";
27402+
s = js_Publish(NULL, js, "stop", "stop", 4, &opts, &jerr);
27403+
testCond(s == NATS_OK);
27404+
2737527405
natsSubscription_Destroy(sub);
2737627406
JS_TEARDOWN;
2737727407
}

0 commit comments

Comments
 (0)