


























@@ -48,6 +48,16 @@ async function expectUploadError(
4848throw new Error("expected upload request error");
4949}
505051+async function expectMissingPath(targetPath: string): Promise<void> {
52+try {
53+await fs.stat(targetPath);
54+} catch (err) {
55+expect((err as { code?: unknown }).code).toBe("ENOENT");
56+return;
57+}
58+throw new Error(`expected missing path: ${targetPath}`);
59+}
60+5161describe("skill upload store", () => {
5262beforeEach(() => {
5363tempDirs = [];
@@ -94,23 +104,19 @@ describe("skill upload store", () => {
94104expect(chunk.receivedBytes).toBe(archive.length);
9510596106const commit = await store.commit({ uploadId: begin.uploadId, sha256: digest });
97-expect(commit).toMatchObject({
98-uploadId: begin.uploadId,
99-receivedBytes: archive.length,
100-sha256: digest,
101-});
107+expect(commit.uploadId).toBe(begin.uploadId);
108+expect(commit.receivedBytes).toBe(archive.length);
109+expect(commit.sha256).toBe(digest);
102110103111const record = await store.withCommittedUpload(begin.uploadId, async (committedRecord) => {
104112return committedRecord;
105113});
106-expect(record).toMatchObject({
107-uploadId: begin.uploadId,
108-slug: "demo-skill",
109-force: false,
110-receivedBytes: archive.length,
111-actualSha256: digest,
112-committed: true,
113-});
114+expect(record.uploadId).toBe(begin.uploadId);
115+expect(record.slug).toBe("demo-skill");
116+expect(record.force).toBe(false);
117+expect(record.receivedBytes).toBe(archive.length);
118+expect(record.actualSha256).toBe(digest);
119+expect(record.committed).toBe(true);
114120await expectUploadError(
115121store.chunk({
116122uploadId: begin.uploadId,
@@ -352,9 +358,7 @@ describe("skill upload store", () => {
352358release.resolve();
353359await expect(pinned).resolves.toBe(true);
354360await sweep;
355-await expect(fs.stat(path.join(rootDir, committed.uploadId))).rejects.toMatchObject({
356-code: "ENOENT",
357-});
361+await expectMissingPath(path.join(rootDir, committed.uploadId));
358362});
359363360364it("does not remove expired idempotent uploads while an install holds the upload lock", async () => {
@@ -402,8 +406,6 @@ describe("skill upload store", () => {
402406await expect(pinned).resolves.toBe(true);
403407const next = await repeated;
404408expect(next.uploadId).not.toBe(committed.uploadId);
405-await expect(fs.stat(path.join(rootDir, committed.uploadId))).rejects.toMatchObject({
406-code: "ENOENT",
407-});
409+await expectMissingPath(path.join(rootDir, committed.uploadId));
408410});
409411});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。