Skip to content

Commit e0320bd

Browse files
Copilotfgreinacher
andcommitted
Simplify templated wildcard test to use single file in fixtures/files directory
Co-authored-by: fgreinacher <[email protected]>
1 parent 58dfb88 commit e0320bd

File tree

5 files changed

+16
-33
lines changed

5 files changed

+16
-33
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Test file content for release with version in filename.

test/fixtures/wildcard-test/release/my-project-v1.0.0-alpha.zip

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/fixtures/wildcard-test/release/my-project-v1.0.0.zip

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/glob-assets.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ test("Expand directories", async (t) => {
191191

192192
t.deepEqual(
193193
sortAssets(globbedAssets),
194-
sortAssets(["dir", "dir/upload_other.txt", "dir/upload.txt", "dir/.dotfile", "dir/file.css"])
194+
sortAssets(["dir", "dir/upload_other.txt", "dir/upload.txt", "dir/.dotfile", "dir/file.css", "dir/versioned", "dir/versioned/upload_v1.0.0.txt"])
195195
);
196196
});
197197

test/publish.test.js

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ test.serial("Publish a release with error response", async (t) => {
714714
});
715715

716716
test.serial("Publish a release with templated wildcard path", async (t) => {
717-
const cwd = "test/fixtures/wildcard-test";
717+
const cwd = "test/fixtures/files";
718718
const owner = "test_user";
719719
const repo = "test_repo";
720720
const env = { GITLAB_TOKEN: "gitlab_token" };
@@ -723,18 +723,12 @@ test.serial("Publish a release with templated wildcard path", async (t) => {
723723
const encodedProjectPath = encodeURIComponent(`${owner}/${repo}`);
724724
const encodedGitTag = encodeURIComponent(nextRelease.gitTag);
725725

726-
// This pattern should match both "my-project-v1.0.0.zip" and "my-project-v1.0.0-alpha.zip"
727-
const assets = ["release/my-project-v${nextRelease.version}*.zip"];
726+
const assets = ["versioned/upload_v${nextRelease.version}.txt"];
728727

729-
const uploaded1 = {
730-
url: "/uploads/my-project-v1.0.0.zip",
731-
alt: "my-project-v1.0.0.zip",
732-
full_path: "/-/project/4/66dbcd21ec5d24ed6ea225176098d52b/my-project-v1.0.0.zip",
733-
};
734-
const uploaded2 = {
735-
url: "/uploads/my-project-v1.0.0-alpha.zip",
736-
alt: "my-project-v1.0.0-alpha.zip",
737-
full_path: "/-/project/4/66dbcd21ec5d24ed6ea225176098d52b/my-project-v1.0.0-alpha.zip",
728+
const uploaded = {
729+
url: "/uploads/upload_v1.0.0.txt",
730+
alt: "upload_v1.0.0.txt",
731+
full_path: "/-/project/4/66dbcd21ec5d24ed6ea225176098d52b/upload_v1.0.0.txt",
738732
};
739733

740734
const gitlab = authenticate(env)
@@ -744,32 +738,22 @@ test.serial("Publish a release with templated wildcard path", async (t) => {
744738
assets: {
745739
links: [
746740
{
747-
name: "my-project-v1.0.0-alpha.zip",
748-
url: `https://gitlab.com${uploaded2.full_path}`,
749-
},
750-
{
751-
name: "my-project-v1.0.0.zip",
752-
url: `https://gitlab.com${uploaded1.full_path}`,
741+
name: "upload_v1.0.0.txt",
742+
url: `https://gitlab.com${uploaded.full_path}`,
753743
},
754744
],
755745
},
756746
})
757747
.reply(200);
758-
const gitlabUpload1 = authenticate(env)
759-
.post(`/projects/${encodedProjectPath}/uploads`, /Content-Disposition.*my-project-v1\.0\.0\.zip/g)
760-
.reply(200, uploaded1);
761-
const gitlabUpload2 = authenticate(env)
762-
.post(`/projects/${encodedProjectPath}/uploads`, /Content-Disposition.*my-project-v1\.0\.0-alpha\.zip/g)
763-
.reply(200, uploaded2);
748+
const gitlabUpload = authenticate(env)
749+
.post(`/projects/${encodedProjectPath}/uploads`, /Content-Disposition.*upload_v1\.0\.0\.txt/g)
750+
.reply(200, uploaded);
764751

765752
const result = await publish({ assets }, { env, cwd, options, nextRelease, logger: t.context.logger });
766753

767754
t.is(result.url, `https://gitlab.com/${owner}/${repo}/-/releases/${encodedGitTag}`);
768-
// Should upload both files that match the wildcard pattern (in alphabetical order)
769-
t.deepEqual(t.context.log.args[0], ["Uploaded file: %s", `https://gitlab.com${uploaded2.full_path}`]);
770-
t.deepEqual(t.context.log.args[1], ["Uploaded file: %s", `https://gitlab.com${uploaded1.full_path}`]);
771-
t.deepEqual(t.context.log.args[2], ["Published GitLab release: %s", nextRelease.gitTag]);
755+
t.deepEqual(t.context.log.args[0], ["Uploaded file: %s", `https://gitlab.com${uploaded.full_path}`]);
756+
t.deepEqual(t.context.log.args[1], ["Published GitLab release: %s", nextRelease.gitTag]);
772757
t.true(gitlab.isDone());
773-
t.true(gitlabUpload1.isDone());
774-
t.true(gitlabUpload2.isDone());
758+
t.true(gitlabUpload.isDone());
775759
});

0 commit comments

Comments
 (0)