From 15fefd93366e98ede1b0739e6e461e85cfbb04c4 Mon Sep 17 00:00:00 2001 From: Aiqiao Yan Date: Wed, 6 May 2020 20:07:39 -0400 Subject: [PATCH] Fix tests --- README.md | 2 +- packages/cache/RELEASES.md | 2 +- packages/cache/__tests__/restoreCache.test.ts | 9 +++------ packages/cache/__tests__/saveCache.test.ts | 6 +++--- packages/cache/package-lock.json | 2 +- packages/cache/package.json | 4 ++-- 6 files changed, 11 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 22fbc27c..df36e70b 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ $ npm install @actions/artifact --save :dart: [@actions/cache](packages/cache) -Provides functions to interact with actions cache. Read more [here](packages/cache) +Provides functions to cache dependencies and build outputs to improve workflow execution time.. Read more [here](packages/cache) ```bash $ npm install @actions/cache --save diff --git a/packages/cache/RELEASES.md b/packages/cache/RELEASES.md index b47fc550..1250c050 100644 --- a/packages/cache/RELEASES.md +++ b/packages/cache/RELEASES.md @@ -1,5 +1,5 @@ # @actions/cache Releases -### 0.0.0 +### 1.0.0 - Initial release \ No newline at end of file diff --git a/packages/cache/__tests__/restoreCache.test.ts b/packages/cache/__tests__/restoreCache.test.ts index 5c807fcf..b466b9af 100644 --- a/packages/cache/__tests__/restoreCache.test.ts +++ b/packages/cache/__tests__/restoreCache.test.ts @@ -57,8 +57,7 @@ test('restore with no cache found', async () => { const key = 'node-test' const infoMock = jest.spyOn(core, 'info') - const clientMock = jest.spyOn(cacheHttpClient, 'getCacheEntry') - clientMock.mockImplementation(async () => { + jest.spyOn(cacheHttpClient, 'getCacheEntry').mockImplementation(async () => { return Promise.resolve(null) }) @@ -74,8 +73,7 @@ test('restore with server error should fail', async () => { const paths = ['node_modules'] const key = 'node-test' - const clientMock = jest.spyOn(cacheHttpClient, 'getCacheEntry') - clientMock.mockImplementation(() => { + jest.spyOn(cacheHttpClient, 'getCacheEntry').mockImplementation(() => { throw new Error('HTTP Error Occurred') }) @@ -91,8 +89,7 @@ test('restore with restore keys and no cache found', async () => { const infoMock = jest.spyOn(core, 'info') - const clientMock = jest.spyOn(cacheHttpClient, 'getCacheEntry') - clientMock.mockImplementation(async () => { + jest.spyOn(cacheHttpClient, 'getCacheEntry').mockImplementation(async () => { return Promise.resolve(null) }) diff --git a/packages/cache/__tests__/saveCache.test.ts b/packages/cache/__tests__/saveCache.test.ts index 2339a197..2fc379b3 100644 --- a/packages/cache/__tests__/saveCache.test.ts +++ b/packages/cache/__tests__/saveCache.test.ts @@ -42,7 +42,7 @@ test('save with large cache outputs should fail', async () => { const createTarMock = jest.spyOn(tar, 'createTar') const cacheSize = 6 * 1024 * 1024 * 1024 //~6GB, over the 5GB limit - jest.spyOn(cacheUtils, 'getArchiveFileSize').mockReturnValue(cacheSize) + jest.spyOn(cacheUtils, 'getArchiveFileSize').mockReturnValueOnce(cacheSize) const compression = CompressionMethod.Gzip const getCompressionMock = jest .spyOn(cacheUtils, 'getCompressionMethod') @@ -108,7 +108,7 @@ test('save with server error should fail', async () => { const saveCacheMock = jest .spyOn(cacheHttpClient, 'saveCache') - .mockImplementationOnce(async () => { + .mockImplementationOnce(() => { throw new Error('HTTP Error Occurred') }) const compression = CompressionMethod.Zstd @@ -116,7 +116,7 @@ test('save with server error should fail', async () => { .spyOn(cacheUtils, 'getCompressionMethod') .mockReturnValueOnce(Promise.resolve(compression)) - await expect(await saveCache([filePath], primaryKey)).rejects.toThrowError( + await expect(saveCache([filePath], primaryKey)).rejects.toThrowError( 'HTTP Error Occurred' ) expect(reserveCacheMock).toHaveBeenCalledTimes(1) diff --git a/packages/cache/package-lock.json b/packages/cache/package-lock.json index 4a263beb..569bab49 100644 --- a/packages/cache/package-lock.json +++ b/packages/cache/package-lock.json @@ -1,6 +1,6 @@ { "name": "@actions/cache", - "version": "0.0.0", + "version": "1.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/packages/cache/package.json b/packages/cache/package.json index 1454048c..2ee2d9bb 100644 --- a/packages/cache/package.json +++ b/packages/cache/package.json @@ -1,8 +1,8 @@ { "name": "@actions/cache", - "version": "0.0.0", + "version": "1.0.0", "preview": true, - "description": "Actions artifact cache lib", + "description": "Actions cache lib", "keywords": [ "github", "actions",