@hot-updater/test-utils 1.0.0-rc.21 → 1.0.0-rc.23
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.
- package/README.md +4 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.mjs +13 -6
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -122,6 +122,10 @@ case, and the `cleanup` it may return runs after the case. `operations` lists
|
|
|
122
122
|
what the adapter implements: the suite fails when one of them is missing and
|
|
123
123
|
skips the cases of the others.
|
|
124
124
|
|
|
125
|
+
With `fetchDownloadUrls: true`, the suite downloads every `http(s)` URL
|
|
126
|
+
`getDownloadUrl` returns and requires the object's bytes, for a spec against a
|
|
127
|
+
real bucket or emulator whose URLs the test can reach.
|
|
128
|
+
|
|
125
129
|
## Plugins and servers
|
|
126
130
|
|
|
127
131
|
- `createPluginTestHarness` runs one server plugin on `createEngine` from
|
package/dist/index.d.mts
CHANGED
|
@@ -197,6 +197,12 @@ interface StorageAdapterTestSuiteOptions {
|
|
|
197
197
|
* it, the suite skips the cases of the operations the adapter lacks.
|
|
198
198
|
*/
|
|
199
199
|
readonly operations?: readonly StorageOperation[];
|
|
200
|
+
/**
|
|
201
|
+
* Fetches every `http(s)` URL `getDownloadUrl` returns and requires the
|
|
202
|
+
* object's bytes. Set it when the adapter runs against a bucket or emulator
|
|
203
|
+
* whose URLs the test can reach.
|
|
204
|
+
*/
|
|
205
|
+
readonly fetchDownloadUrls?: boolean;
|
|
200
206
|
}
|
|
201
207
|
/**
|
|
202
208
|
* The storage adapter contract that deploy, patch, the Console, the server,
|
package/dist/index.mjs
CHANGED
|
@@ -2452,15 +2452,15 @@ const namingCalls = (storage) => {
|
|
|
2452
2452
|
const storageCase = (title, operations, run) => ({
|
|
2453
2453
|
title,
|
|
2454
2454
|
operations,
|
|
2455
|
-
run: async ({ storage,
|
|
2455
|
+
run: async ({ storage, ...context }) => {
|
|
2456
2456
|
assertStorageOperations(storage, [
|
|
2457
2457
|
"put",
|
|
2458
2458
|
"get",
|
|
2459
2459
|
...operations
|
|
2460
2460
|
]);
|
|
2461
2461
|
await run({
|
|
2462
|
-
|
|
2463
|
-
|
|
2462
|
+
...context,
|
|
2463
|
+
storage: namingCalls(storage)
|
|
2464
2464
|
});
|
|
2465
2465
|
}
|
|
2466
2466
|
});
|
|
@@ -2629,15 +2629,21 @@ const storageAdapterTestCases = [
|
|
|
2629
2629
|
}), "another protocol");
|
|
2630
2630
|
await expectObject(storage, storageUri, bytes);
|
|
2631
2631
|
}),
|
|
2632
|
-
storageCase("resolves a download URL for a stored object", ["getDownloadUrl"], async ({ storage, basePath }) => {
|
|
2632
|
+
storageCase("resolves a download URL for a stored object", ["getDownloadUrl"], async ({ storage, basePath, fetchDownloadUrls }) => {
|
|
2633
2633
|
const objects = objectsOf(storage, basePath);
|
|
2634
2634
|
for (const key of ["download/object.txt", ...SPECIAL_KEYS]) {
|
|
2635
|
-
const
|
|
2635
|
+
const bytes = encode(key);
|
|
2636
|
+
const storageUri = await objects.put(key, bytes);
|
|
2636
2637
|
const { url } = await storage.getDownloadUrl({ storageUri });
|
|
2637
2638
|
const label = `getDownloadUrl("${storageUri}") returned "${url}"`;
|
|
2638
2639
|
expect(typeof url, label).toBe("string");
|
|
2639
2640
|
if (/^[a-z][a-z\d+.-]*:/i.test(url)) {
|
|
2640
2641
|
expect(["http:", "https:"], `${label}; a URL must use http(s)`).toContain(new URL(url).protocol);
|
|
2642
|
+
if (fetchDownloadUrls) {
|
|
2643
|
+
const response = await fetch(url);
|
|
2644
|
+
expect(response.status, `${label}, which answered`).toBe(200);
|
|
2645
|
+
expectBytes(new Uint8Array(await response.arrayBuffer()), bytes, `${label}, whose download`);
|
|
2646
|
+
}
|
|
2641
2647
|
continue;
|
|
2642
2648
|
}
|
|
2643
2649
|
expect(parseStorageDownloadPath(url)?.storageUri, `${label}; a path must be the /storage/ path of the same URI`).toBe(storageUri);
|
|
@@ -2724,7 +2730,8 @@ const setupStorageAdapterTestSuite = (options) => {
|
|
|
2724
2730
|
if (declared === void 0 && missing.length > 0) context.skip(`${storage.name} lacks ${missing.join(", ")}`);
|
|
2725
2731
|
await testCase.run({
|
|
2726
2732
|
storage,
|
|
2727
|
-
basePath
|
|
2733
|
+
basePath,
|
|
2734
|
+
fetchDownloadUrls: options.fetchDownloadUrls
|
|
2728
2735
|
});
|
|
2729
2736
|
} finally {
|
|
2730
2737
|
await cleanup?.();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/test-utils",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.23",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Test utilities for Hot Updater packages",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"mysql2": "*",
|
|
51
51
|
"pg": "*",
|
|
52
52
|
"vitest": "^4.0.0",
|
|
53
|
-
"@hot-updater/plugin-insights": "^1.0.0-rc.
|
|
54
|
-
"@hot-updater/plugin-core": "^1.0.0-rc.
|
|
55
|
-
"@hot-updater/
|
|
56
|
-
"@hot-updater/
|
|
53
|
+
"@hot-updater/plugin-insights": "^1.0.0-rc.23",
|
|
54
|
+
"@hot-updater/plugin-core": "^1.0.0-rc.23",
|
|
55
|
+
"@hot-updater/server": "^1.0.0-rc.23",
|
|
56
|
+
"@hot-updater/protocol": "^1.0.0-rc.23"
|
|
57
57
|
},
|
|
58
58
|
"peerDependenciesMeta": {
|
|
59
59
|
"@electric-sql/pglite": {
|
|
@@ -83,11 +83,11 @@
|
|
|
83
83
|
"typescript": "npm:@typescript/typescript6@6.0.2",
|
|
84
84
|
"vitest": "4.1.4",
|
|
85
85
|
"workspace-tools": "^0.41.7",
|
|
86
|
-
"@hot-updater/
|
|
87
|
-
"@hot-updater/
|
|
88
|
-
"@hot-updater/
|
|
89
|
-
"@hot-updater/server": "1.0.0-rc.
|
|
90
|
-
"@hot-updater/
|
|
86
|
+
"@hot-updater/plugin-insights": "1.0.0-rc.23",
|
|
87
|
+
"@hot-updater/js": "1.0.0-rc.23",
|
|
88
|
+
"@hot-updater/plugin-core": "1.0.0-rc.23",
|
|
89
|
+
"@hot-updater/server": "1.0.0-rc.23",
|
|
90
|
+
"@hot-updater/protocol": "1.0.0-rc.23"
|
|
91
91
|
},
|
|
92
92
|
"inlinedDependencies": {
|
|
93
93
|
"@nodelib/fs.scandir": "2.1.5",
|