@@ -20,7 +20,15 @@ test("sanitizeArtifactName", (t) => {
2020 ) ;
2121} ) ;
2222
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 ) => {
2432 // Test that no error is thrown if artifacts list is empty.
2533 const logger = getActionsLogger ( ) ;
2634 await t . notThrowsAsync ( async ( ) => {
@@ -40,7 +48,7 @@ test("uploadDebugArtifacts when artifacts empty", async (t) => {
4048 } ) ;
4149} ) ;
4250
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 ) => {
4452 // Test that the artifact is uploaded.
4553 const logger = getActionsLogger ( ) ;
4654 await t . notThrowsAsync ( async ( ) => {
@@ -54,13 +62,14 @@ test("uploadDebugArtifacts when no codeql version is used", async (t) => {
5462 ) ;
5563 t . is (
5664 uploaded ,
65+ // The failure is expected since we don't want to actually upload any artifacts in unit tests.
5766 "upload-failed" ,
5867 "Expect failure to upload artifacts since root dir does not exist" ,
5968 ) ;
6069 } ) ;
6170} ) ;
6271
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 ) => {
6473 // Test that the artifact is uploaded.
6574 const logger = getActionsLogger ( ) ;
6675 await t . notThrowsAsync ( async ( ) => {
@@ -74,13 +83,14 @@ test("uploadDebugArtifacts when new codeql version is used", async (t) => {
7483 ) ;
7584 t . is (
7685 uploaded ,
86+ // The failure is expected since we don't want to actually upload any artifacts in unit tests.
7787 "upload-failed" ,
7888 "Expect failure to upload artifacts since root dir does not exist" ,
7989 ) ;
8090 } ) ;
8191} ) ;
8292
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 ) => {
8494 // Test that the artifact is not uploaded.
8595 const logger = getActionsLogger ( ) ;
8696 await t . notThrowsAsync ( async ( ) => {
0 commit comments