Skip to content

Commit a494b71

Browse files
committed
nextwork errros
1 parent c585a14 commit a494b71

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

test/routes/delete.test.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,68 @@ describe("Delete network failure and passthrough behavior. __rest __core", () =
104104
.delete("/delete/00000")
105105
assert.equal(response.statusCode, 502)
106106
})
107+
108+
it("Preserves upstream text error message for body delete when response is non-ok.", async () => {
109+
global.fetch = async () => ({
110+
ok: false,
111+
status: 503,
112+
text: async () => "Upstream body delete failure"
113+
})
114+
115+
const response = await request(routeTester)
116+
.delete("/delete")
117+
.set("Content-Type", "application/json")
118+
.send({ "@id": rerumUri })
119+
120+
assert.equal(response.statusCode, 502)
121+
assert.match(response.text, /Upstream body delete failure/)
122+
})
123+
124+
it("Falls back to generic RERUM error text for body delete when upstream .text() throws.", async () => {
125+
global.fetch = async () => ({
126+
ok: false,
127+
status: 500,
128+
text: async () => {
129+
throw new Error("text stream consumed")
130+
}
131+
})
132+
133+
const response = await request(routeTester)
134+
.delete("/delete")
135+
.set("Content-Type", "application/json")
136+
.send({ "@id": rerumUri })
137+
138+
assert.equal(response.statusCode, 502)
139+
assert.match(response.text, /A RERUM error occurred/)
140+
})
141+
142+
it("Preserves upstream text error message for path delete when response is non-ok.", async () => {
143+
global.fetch = async () => ({
144+
ok: false,
145+
status: 503,
146+
text: async () => "Upstream path delete failure"
147+
})
148+
149+
const response = await request(routeTester)
150+
.delete("/delete/00000")
151+
152+
assert.equal(response.statusCode, 502)
153+
assert.match(response.text, /Upstream path delete failure/)
154+
})
155+
156+
it("Falls back to generic RERUM error text for path delete when upstream .text() throws.", async () => {
157+
global.fetch = async () => ({
158+
ok: false,
159+
status: 500,
160+
text: async () => {
161+
throw new Error("text stream consumed")
162+
}
163+
})
164+
165+
const response = await request(routeTester)
166+
.delete("/delete/00000")
167+
168+
assert.equal(response.statusCode, 502)
169+
assert.match(response.text, /A RERUM error occurred/)
170+
})
107171
})

0 commit comments

Comments
 (0)