@@ -20,7 +20,15 @@ test("sanitizeArtifactName", (t) => {
20
20
) ;
21
21
} ) ;
22
22
23
- test ( "uploadDebugArtifacts when artifacts empty" , async ( t ) => {
23
+ // These next tests check the correctness of the logic to determine whether or not
24
+ // artifacts are uploaded in debug mode. Since it's not easy to mock the actual
25
+ // call to upload an artifact, we just check that we get an "upload-failed" result,
26
+ // instead of actually uploading the artifact.
27
+ //
28
+ // For tests where we expect artifact upload to be blocked, we check for a different
29
+ // response from the function.
30
+
31
+ test ( "uploadDebugArtifacts when artifacts empty should emit 'no-artifacts-to-upload'" , async ( t ) => {
24
32
// Test that no error is thrown if artifacts list is empty.
25
33
const logger = getActionsLogger ( ) ;
26
34
await t . notThrowsAsync ( async ( ) => {
@@ -40,7 +48,7 @@ test("uploadDebugArtifacts when artifacts empty", async (t) => {
40
48
} ) ;
41
49
} ) ;
42
50
43
- test ( "uploadDebugArtifacts when no codeql version is used" , async ( t ) => {
51
+ test ( "uploadDebugArtifacts when no codeql version is used should invoke artifact upload " , async ( t ) => {
44
52
// Test that the artifact is uploaded.
45
53
const logger = getActionsLogger ( ) ;
46
54
await t . notThrowsAsync ( async ( ) => {
@@ -54,13 +62,14 @@ test("uploadDebugArtifacts when no codeql version is used", async (t) => {
54
62
) ;
55
63
t . is (
56
64
uploaded ,
65
+ // The failure is expected since we don't want to actually upload any artifacts in unit tests.
57
66
"upload-failed" ,
58
67
"Expect failure to upload artifacts since root dir does not exist" ,
59
68
) ;
60
69
} ) ;
61
70
} ) ;
62
71
63
- test ( "uploadDebugArtifacts when new codeql version is used" , async ( t ) => {
72
+ test ( "uploadDebugArtifacts when new codeql version is used should invoke artifact upload " , async ( t ) => {
64
73
// Test that the artifact is uploaded.
65
74
const logger = getActionsLogger ( ) ;
66
75
await t . notThrowsAsync ( async ( ) => {
@@ -74,13 +83,14 @@ test("uploadDebugArtifacts when new codeql version is used", async (t) => {
74
83
) ;
75
84
t . is (
76
85
uploaded ,
86
+ // The failure is expected since we don't want to actually upload any artifacts in unit tests.
77
87
"upload-failed" ,
78
88
"Expect failure to upload artifacts since root dir does not exist" ,
79
89
) ;
80
90
} ) ;
81
91
} ) ;
82
92
83
- test ( "uploadDebugArtifacts when old codeql is used" , async ( t ) => {
93
+ test ( "uploadDebugArtifacts when old codeql is used should avoid trying to upload artifacts " , async ( t ) => {
84
94
// Test that the artifact is not uploaded.
85
95
const logger = getActionsLogger ( ) ;
86
96
await t . notThrowsAsync ( async ( ) => {
0 commit comments