Skip to content

Commit f950f7f

Browse files
committed
Add unit tests for getArtifactSuffix
1 parent 69173ea commit f950f7f

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/debug-artifacts.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,29 @@ test("sanitizeArtifactName", (t) => {
2424
);
2525
});
2626

27+
test("getArtifactSuffix", (t) => {
28+
// No suffix if there's no `matrix` input, it is invalid, or has no keys.
29+
t.is(debugArtifacts.getArtifactSuffix(undefined), "");
30+
t.is(debugArtifacts.getArtifactSuffix(""), "");
31+
t.is(debugArtifacts.getArtifactSuffix("invalid json"), "");
32+
t.is(debugArtifacts.getArtifactSuffix("{}"), "");
33+
34+
// Suffixes for non-empty, valid `matrix` inputs.
35+
const testMatrices = [
36+
{ language: "go" },
37+
{ language: "javascript", "build-mode": "none" },
38+
];
39+
40+
for (const testMatrix of testMatrices) {
41+
const suffix = debugArtifacts.getArtifactSuffix(JSON.stringify(testMatrix));
42+
t.not(suffix, "");
43+
44+
for (const key of Object.keys(testMatrix)) {
45+
t.assert(suffix.includes(testMatrix[key] as string));
46+
}
47+
}
48+
});
49+
2750
// These next tests check the correctness of the logic to determine whether or not
2851
// artifacts are uploaded in debug mode. Since it's not easy to mock the actual
2952
// call to upload an artifact, we just check that we get an "upload-failed" result,

0 commit comments

Comments
 (0)