package api // P6 owner review: with batch off (disabled, or the store did not open) every batch endpoint // answers 503; none of them panics on the nil runner. import ( "net/http" "testing" ) func TestBatchDisabled(t *testing.T) { s, keys := newBatchServer(t, "test") s.Batch.Close() s.Batch = nil for _, c := range []struct{ method, path string }{ {http.MethodPost, "/v1/batch"}, {http.MethodGet, "/v1/batch/x"}, {http.MethodGet, "/v1/batch/x/0"}, {http.MethodDelete, "/v1/batch/x"}, } { var body any if c.method == http.MethodPost { body = map[string]any{"targets": []any{map[string]any{"url": "http://127.0.0.1/"}}} } if rec := batchReq(t, s, c.method, c.path, keys["test"], body); rec.Code != 503 { t.Errorf("%s %s: %d %s, want 503", c.method, c.path, rec.Code, rec.Body.String()) } } }