@durable-streams/client-conformance-tests 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -117,11 +117,8 @@ async function handleCommand(command) {
|
|
|
117
117
|
case `create`: try {
|
|
118
118
|
const url = `${serverUrl}${command.path}`;
|
|
119
119
|
const contentType = command.contentType ?? `application/octet-stream`;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
await __durable_streams_client.DurableStream.head({ url });
|
|
123
|
-
alreadyExists = true;
|
|
124
|
-
} catch {}
|
|
120
|
+
const existsCheck = await __durable_streams_client.DurableStream.head({ url });
|
|
121
|
+
const alreadyExists = existsCheck.exists;
|
|
125
122
|
const ds = await __durable_streams_client.DurableStream.create({
|
|
126
123
|
url,
|
|
127
124
|
contentType,
|
|
@@ -137,7 +134,7 @@ async function handleCommand(command) {
|
|
|
137
134
|
type: `create`,
|
|
138
135
|
success: true,
|
|
139
136
|
status: alreadyExists ? 200 : 201,
|
|
140
|
-
offset: head.offset
|
|
137
|
+
offset: head.exists ? head.offset : void 0
|
|
141
138
|
};
|
|
142
139
|
} catch (err) {
|
|
143
140
|
return errorResult(`create`, err);
|
|
@@ -149,6 +146,14 @@ async function handleCommand(command) {
|
|
|
149
146
|
headers: command.headers
|
|
150
147
|
});
|
|
151
148
|
const head = await ds.head();
|
|
149
|
+
if (!head.exists) return {
|
|
150
|
+
type: `error`,
|
|
151
|
+
success: false,
|
|
152
|
+
commandType: `connect`,
|
|
153
|
+
status: 404,
|
|
154
|
+
errorCode: require_protocol.ErrorCodes.NOT_FOUND,
|
|
155
|
+
message: `Stream not found: ${command.path}`
|
|
156
|
+
};
|
|
152
157
|
if (head.contentType) streamContentTypes.set(command.path, head.contentType);
|
|
153
158
|
return {
|
|
154
159
|
type: `connect`,
|
|
@@ -182,7 +187,7 @@ async function handleCommand(command) {
|
|
|
182
187
|
type: `append`,
|
|
183
188
|
success: true,
|
|
184
189
|
status: 200,
|
|
185
|
-
offset: head.offset,
|
|
190
|
+
offset: head.exists ? head.offset : void 0,
|
|
186
191
|
headersSent: Object.keys(headersSent).length > 0 ? headersSent : void 0,
|
|
187
192
|
paramsSent: Object.keys(paramsSent).length > 0 ? paramsSent : void 0
|
|
188
193
|
};
|
|
@@ -338,6 +343,14 @@ async function handleCommand(command) {
|
|
|
338
343
|
url,
|
|
339
344
|
headers: command.headers
|
|
340
345
|
});
|
|
346
|
+
if (!result.exists) return {
|
|
347
|
+
type: `error`,
|
|
348
|
+
success: false,
|
|
349
|
+
commandType: `head`,
|
|
350
|
+
status: 404,
|
|
351
|
+
errorCode: require_protocol.ErrorCodes.NOT_FOUND,
|
|
352
|
+
message: `Stream not found: ${command.path}`
|
|
353
|
+
};
|
|
341
354
|
if (result.contentType) streamContentTypes.set(command.path, result.contentType);
|
|
342
355
|
return {
|
|
343
356
|
type: `head`,
|
|
@@ -115,11 +115,8 @@ async function handleCommand(command) {
|
|
|
115
115
|
case `create`: try {
|
|
116
116
|
const url = `${serverUrl}${command.path}`;
|
|
117
117
|
const contentType = command.contentType ?? `application/octet-stream`;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
await DurableStream.head({ url });
|
|
121
|
-
alreadyExists = true;
|
|
122
|
-
} catch {}
|
|
118
|
+
const existsCheck = await DurableStream.head({ url });
|
|
119
|
+
const alreadyExists = existsCheck.exists;
|
|
123
120
|
const ds = await DurableStream.create({
|
|
124
121
|
url,
|
|
125
122
|
contentType,
|
|
@@ -135,7 +132,7 @@ async function handleCommand(command) {
|
|
|
135
132
|
type: `create`,
|
|
136
133
|
success: true,
|
|
137
134
|
status: alreadyExists ? 200 : 201,
|
|
138
|
-
offset: head.offset
|
|
135
|
+
offset: head.exists ? head.offset : void 0
|
|
139
136
|
};
|
|
140
137
|
} catch (err) {
|
|
141
138
|
return errorResult(`create`, err);
|
|
@@ -147,6 +144,14 @@ async function handleCommand(command) {
|
|
|
147
144
|
headers: command.headers
|
|
148
145
|
});
|
|
149
146
|
const head = await ds.head();
|
|
147
|
+
if (!head.exists) return {
|
|
148
|
+
type: `error`,
|
|
149
|
+
success: false,
|
|
150
|
+
commandType: `connect`,
|
|
151
|
+
status: 404,
|
|
152
|
+
errorCode: ErrorCodes.NOT_FOUND,
|
|
153
|
+
message: `Stream not found: ${command.path}`
|
|
154
|
+
};
|
|
150
155
|
if (head.contentType) streamContentTypes.set(command.path, head.contentType);
|
|
151
156
|
return {
|
|
152
157
|
type: `connect`,
|
|
@@ -180,7 +185,7 @@ async function handleCommand(command) {
|
|
|
180
185
|
type: `append`,
|
|
181
186
|
success: true,
|
|
182
187
|
status: 200,
|
|
183
|
-
offset: head.offset,
|
|
188
|
+
offset: head.exists ? head.offset : void 0,
|
|
184
189
|
headersSent: Object.keys(headersSent).length > 0 ? headersSent : void 0,
|
|
185
190
|
paramsSent: Object.keys(paramsSent).length > 0 ? paramsSent : void 0
|
|
186
191
|
};
|
|
@@ -336,6 +341,14 @@ async function handleCommand(command) {
|
|
|
336
341
|
url,
|
|
337
342
|
headers: command.headers
|
|
338
343
|
});
|
|
344
|
+
if (!result.exists) return {
|
|
345
|
+
type: `error`,
|
|
346
|
+
success: false,
|
|
347
|
+
commandType: `head`,
|
|
348
|
+
status: 404,
|
|
349
|
+
errorCode: ErrorCodes.NOT_FOUND,
|
|
350
|
+
message: `Stream not found: ${command.path}`
|
|
351
|
+
};
|
|
339
352
|
if (result.contentType) streamContentTypes.set(command.path, result.contentType);
|
|
340
353
|
return {
|
|
341
354
|
type: `head`,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@durable-streams/client-conformance-tests",
|
|
3
3
|
"description": "Conformance test suite for Durable Streams client implementations (producer and consumer)",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.4",
|
|
5
5
|
"author": "Durable Stream contributors",
|
|
6
6
|
"bin": {
|
|
7
7
|
"client-conformance-tests": "./dist/cli.js",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"fast-check": "^4.4.0",
|
|
15
15
|
"tsx": "^4.19.2",
|
|
16
16
|
"yaml": "^2.7.1",
|
|
17
|
-
"@durable-streams/client": "0.2.
|
|
18
|
-
"@durable-streams/server": "0.
|
|
17
|
+
"@durable-streams/client": "0.2.3",
|
|
18
|
+
"@durable-streams/server": "0.3.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"tsdown": "^0.9.0",
|
|
@@ -194,14 +194,9 @@ async function handleCommand(command: TestCommand): Promise<TestResult> {
|
|
|
194
194
|
const url = `${serverUrl}${command.path}`
|
|
195
195
|
const contentType = command.contentType ?? `application/octet-stream`
|
|
196
196
|
|
|
197
|
-
// Check if stream already exists by trying
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
await DurableStream.head({ url })
|
|
201
|
-
alreadyExists = true
|
|
202
|
-
} catch {
|
|
203
|
-
// Stream doesn't exist, which is expected for new creates
|
|
204
|
-
}
|
|
197
|
+
// Check if stream already exists by trying HEAD first
|
|
198
|
+
const existsCheck = await DurableStream.head({ url })
|
|
199
|
+
const alreadyExists = existsCheck.exists
|
|
205
200
|
|
|
206
201
|
const ds = await DurableStream.create({
|
|
207
202
|
url,
|
|
@@ -222,7 +217,7 @@ async function handleCommand(command: TestCommand): Promise<TestResult> {
|
|
|
222
217
|
type: `create`,
|
|
223
218
|
success: true,
|
|
224
219
|
status: alreadyExists ? 200 : 201, // 201 for new, 200 for idempotent
|
|
225
|
-
offset: head.offset,
|
|
220
|
+
offset: head.exists ? head.offset : undefined,
|
|
226
221
|
}
|
|
227
222
|
} catch (err) {
|
|
228
223
|
return errorResult(`create`, err)
|
|
@@ -239,6 +234,17 @@ async function handleCommand(command: TestCommand): Promise<TestResult> {
|
|
|
239
234
|
|
|
240
235
|
const head = await ds.head()
|
|
241
236
|
|
|
237
|
+
if (!head.exists) {
|
|
238
|
+
return {
|
|
239
|
+
type: `error`,
|
|
240
|
+
success: false,
|
|
241
|
+
commandType: `connect`,
|
|
242
|
+
status: 404,
|
|
243
|
+
errorCode: ErrorCodes.NOT_FOUND,
|
|
244
|
+
message: `Stream not found: ${command.path}`,
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
242
248
|
// Cache the content-type for this stream
|
|
243
249
|
if (head.contentType) {
|
|
244
250
|
streamContentTypes.set(command.path, head.contentType)
|
|
@@ -294,7 +300,7 @@ async function handleCommand(command: TestCommand): Promise<TestResult> {
|
|
|
294
300
|
type: `append`,
|
|
295
301
|
success: true,
|
|
296
302
|
status: 200,
|
|
297
|
-
offset: head.offset,
|
|
303
|
+
offset: head.exists ? head.offset : undefined,
|
|
298
304
|
headersSent:
|
|
299
305
|
Object.keys(headersSent).length > 0 ? headersSent : undefined,
|
|
300
306
|
paramsSent:
|
|
@@ -537,6 +543,17 @@ async function handleCommand(command: TestCommand): Promise<TestResult> {
|
|
|
537
543
|
headers: command.headers,
|
|
538
544
|
})
|
|
539
545
|
|
|
546
|
+
if (!result.exists) {
|
|
547
|
+
return {
|
|
548
|
+
type: `error`,
|
|
549
|
+
success: false,
|
|
550
|
+
commandType: `head`,
|
|
551
|
+
status: 404,
|
|
552
|
+
errorCode: ErrorCodes.NOT_FOUND,
|
|
553
|
+
message: `Stream not found: ${command.path}`,
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
|
|
540
557
|
// Cache content-type
|
|
541
558
|
if (result.contentType) {
|
|
542
559
|
streamContentTypes.set(command.path, result.contentType)
|