mirror of
https://github.com/binwiederhier/ntfy.git
synced 2026-11-10 14:44:04 +08:00
Test that a scheduled message is replaced when the sequence ID comes as a parameter
The existing update tests only set the sequence ID in the path; this covers the ?sid= form, which takes the same DeleteScheduledBySequenceID path.
This commit is contained in:
1 parent
ac512e96c0
commit
87a27188f1
1 file changed
+26
@@ -4906,6 +4906,32 @@ func TestServer_UpdateScheduledMessage(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestServer_UpdateScheduledMessage_SequenceIDParam(t *testing.T) {
|
||||
// Same as TestServer_UpdateScheduledMessage, but with the sequence ID passed as a query
|
||||
// parameter instead of in the path; the scheduled message must still be replaced
|
||||
forEachBackend(t, func(t *testing.T, databaseURL string) {
|
||||
t.Parallel()
|
||||
s := newTestServer(t, newTestConfig(t, databaseURL))
|
||||
response := request(t, s, "PUT", "/mytopic?sid=sched-seq&delay=1h", "original scheduled message", nil)
|
||||
require.Equal(t, 200, response.Code)
|
||||
msg1 := toMessage(t, response.Body.String())
|
||||
require.Equal(t, "sched-seq", msg1.SequenceID)
|
||||
|
||||
response = request(t, s, "PUT", "/mytopic?sid=sched-seq&delay=2h", "updated scheduled message", nil)
|
||||
require.Equal(t, 200, response.Code)
|
||||
msg2 := toMessage(t, response.Body.String())
|
||||
require.Equal(t, "sched-seq", msg2.SequenceID)
|
||||
require.NotEqual(t, msg1.ID, msg2.ID)
|
||||
|
||||
response = request(t, s, "GET", "/mytopic/json?poll=1&scheduled=1", "", nil)
|
||||
require.Equal(t, 200, response.Code)
|
||||
messages := toMessages(t, response.Body.String())
|
||||
require.Equal(t, 1, len(messages))
|
||||
require.Equal(t, msg2.ID, messages[0].ID)
|
||||
require.Equal(t, "updated scheduled message", messages[0].Message)
|
||||
})
|
||||
}
|
||||
|
||||
func TestServer_PublishWithoutSequenceID_NoDatabaseRoundTrip(t *testing.T) {
|
||||
// A message without a client-provided sequence ID gets its own fresh ID as sequence ID, so no
|
||||
// scheduled message can share it; publishing it must not wait for the database. Each round
|
||||
|
||||
Reference in new issue
Block a user