mirror of
https://github.com/multipleof4/ntfy.git
synced 2026-10-16 16:37:55 +00:00
Additional test
This commit is contained in:
@@ -3700,9 +3700,12 @@ func (b *slowBody) Close() error { return nil }
|
|||||||
func TestServer_MessageTemplate_SlowUpload_NotCountedAgainstDeadline(t *testing.T) {
|
func TestServer_MessageTemplate_SlowUpload_NotCountedAgainstDeadline(t *testing.T) {
|
||||||
s := newTestServer(t, newTestConfig(t, ""))
|
s := newTestServer(t, newTestConfig(t, ""))
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
// The loop makes the template execute enough nodes (>256) to actually hit the deadline check,
|
||||||
|
// so this test distinguishes correct behavior from a deadline that includes upload time -- yet
|
||||||
|
// it runs in ~1ms, far under the deadline, so on correct code it renders fine.
|
||||||
response := request(t, s, "POST", "/mytopic", `{"foo":"bar"}`, map[string]string{
|
response := request(t, s, "POST", "/mytopic", `{"foo":"bar"}`, map[string]string{
|
||||||
"Template": "yes",
|
"Template": "yes",
|
||||||
"X-Message": "hello {{.foo}}",
|
"X-Message": `{{range until 5000}}{{$x := .}}{{end}}hello {{.foo}}`,
|
||||||
}, func(r *http.Request) {
|
}, func(r *http.Request) {
|
||||||
r.Body = &slowBody{data: []byte(`{"foo":"bar"}`), delay: 3 * templateMaxExecutionTime}
|
r.Body = &slowBody{data: []byte(`{"foo":"bar"}`), delay: 3 * templateMaxExecutionTime}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user