Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Aiqiao Yan authored and Aiqiao Yan committed May 12, 2020
1 parent 7409ad5 commit 15fefd9
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/cache/RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# @actions/cache Releases

### 0.0.0
### 1.0.0

- Initial release
9 changes: 3 additions & 6 deletions packages/cache/__tests__/restoreCache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})

Expand All @@ -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')
})

Expand All @@ -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)
})

Expand Down
6 changes: 3 additions & 3 deletions packages/cache/__tests__/saveCache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -108,15 +108,15 @@ 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
const getCompressionMock = jest
.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)
Expand Down
2 changes: 1 addition & 1 deletion packages/cache/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/cache/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 15fefd9

Please sign in to comment.