From 94fe8e1a0dbf7b636df311f77f54f588a953cb57 Mon Sep 17 00:00:00 2001 From: Sankalp Kotewar <98868223+kotewar@users.noreply.github.com> Date: Mon, 23 May 2022 06:32:13 +0000 Subject: [PATCH] Added unit test case for #624 --- __tests__/saveCache.test.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/__tests__/saveCache.test.ts b/__tests__/saveCache.test.ts index 4627f2c..bacb2e1 100644 --- a/__tests__/saveCache.test.ts +++ b/__tests__/saveCache.test.ts @@ -290,3 +290,14 @@ test('save with valid inputs uploads a cache', async () => { expect(saveCacheMock).toHaveBeenCalledWith(cacheId, archiveFile, undefined) expect(getCompressionMock).toHaveBeenCalledTimes(1) }) + +test('save with non existing path should not save cache', async () => { + const paths: string[] = ['aPathThatDoesnotExist'] + const primaryKey = 'Linux-node-bb828da54c148048dd17899ba9fda624811cfb43' + jest.spyOn(cacheUtils, 'resolvePaths').mockImplementation(async filePaths => { + return [] + }) + await expect(saveCache(paths, primaryKey)).rejects.toThrowError( + `Path Validation Error: Path(s) specified in the action do not exist, hence no cache is being saved.` + ) +})