11import os from 'os' ;
22import { join } from 'path' ;
33import * as remoteCache from '@actions/cache' ;
4+ import * as core from '@actions/core' ;
45import * as toolCache from '@actions/tool-cache' ;
56
67import * as cache from '../src/cache' ;
@@ -34,6 +35,7 @@ describe('fromRemoteCache', () => {
3435 beforeEach ( ( ) => {
3536 spy = {
3637 restore : jest . spyOn ( remoteCache , 'restoreCache' ) . mockImplementation ( ) ,
38+ warning : jest . spyOn ( core , 'warning' ) . mockImplementation ( ) ,
3739 } ;
3840 } ) ;
3941
@@ -44,6 +46,7 @@ describe('fromRemoteCache', () => {
4446 afterAll ( ( ) => {
4547 utils . restoreEnv ( ) ;
4648 spy . restore . mockRestore ( ) ;
49+ spy . warning . mockRestore ( ) ;
4750 } ) ;
4851
4952 it ( 'restores remote cache with default key' , async ( ) => {
@@ -80,6 +83,7 @@ describe('fromRemoteCache', () => {
8083 const error = new Error ( 'Cache Service Url not found, unable to restore cache.' ) ;
8184 spy . restore . mockRejectedValueOnce ( error ) ;
8285 await expect ( cache . fromRemoteCache ( '3.20.1' , 'yarn' ) ) . resolves . toBeUndefined ( ) ;
86+ expect ( spy . warning ) . toHaveBeenCalledWith ( expect . stringContaining ( 'Skipping remote cache' ) ) ;
8387 } ) ;
8488} ) ;
8589
@@ -89,11 +93,13 @@ describe('toRemoteCache', () => {
8993 beforeEach ( ( ) => {
9094 spy = {
9195 save : jest . spyOn ( remoteCache , 'saveCache' ) . mockImplementation ( ) ,
96+ warning : jest . spyOn ( core , 'warning' ) . mockImplementation ( ) ,
9297 } ;
9398 } ) ;
9499
95100 afterAll ( ( ) => {
96101 spy . save . mockRestore ( ) ;
102+ spy . warning . mockRestore ( ) ;
97103 } ) ;
98104
99105 it ( 'saves remote cache with default key' , async ( ) => {
@@ -120,5 +126,6 @@ describe('toRemoteCache', () => {
120126 const error = new Error ( 'Cache Service Url not found, unable to restore cache.' ) ;
121127 spy . save . mockRejectedValueOnce ( error ) ;
122128 await expect ( cache . toRemoteCache ( join ( 'local' , 'path' ) , '3.20.1' , 'yarn' ) ) . resolves . toBeUndefined ( ) ;
129+ expect ( spy . warning ) . toHaveBeenCalledWith ( expect . stringContaining ( 'Skipping remote cache' ) ) ;
123130 } ) ;
124131} ) ;
0 commit comments