Skip to content

Commit 15fefd9

Browse files
Aiqiao YanAiqiao Yan
authored andcommitted
Fix tests
1 parent 7409ad5 commit 15fefd9

File tree

6 files changed

+11
-14
lines changed

6 files changed

+11
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ $ npm install @actions/artifact --save
8484

8585
:dart: [@actions/cache](packages/cache)
8686

87-
Provides functions to interact with actions cache. Read more [here](packages/cache)
87+
Provides functions to cache dependencies and build outputs to improve workflow execution time.. Read more [here](packages/cache)
8888

8989
```bash
9090
$ npm install @actions/cache --save

packages/cache/RELEASES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# @actions/cache Releases
22

3-
### 0.0.0
3+
### 1.0.0
44

55
- Initial release

packages/cache/__tests__/restoreCache.test.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ test('restore with no cache found', async () => {
5757
const key = 'node-test'
5858

5959
const infoMock = jest.spyOn(core, 'info')
60-
const clientMock = jest.spyOn(cacheHttpClient, 'getCacheEntry')
61-
clientMock.mockImplementation(async () => {
60+
jest.spyOn(cacheHttpClient, 'getCacheEntry').mockImplementation(async () => {
6261
return Promise.resolve(null)
6362
})
6463

@@ -74,8 +73,7 @@ test('restore with server error should fail', async () => {
7473
const paths = ['node_modules']
7574
const key = 'node-test'
7675

77-
const clientMock = jest.spyOn(cacheHttpClient, 'getCacheEntry')
78-
clientMock.mockImplementation(() => {
76+
jest.spyOn(cacheHttpClient, 'getCacheEntry').mockImplementation(() => {
7977
throw new Error('HTTP Error Occurred')
8078
})
8179

@@ -91,8 +89,7 @@ test('restore with restore keys and no cache found', async () => {
9189

9290
const infoMock = jest.spyOn(core, 'info')
9391

94-
const clientMock = jest.spyOn(cacheHttpClient, 'getCacheEntry')
95-
clientMock.mockImplementation(async () => {
92+
jest.spyOn(cacheHttpClient, 'getCacheEntry').mockImplementation(async () => {
9693
return Promise.resolve(null)
9794
})
9895

packages/cache/__tests__/saveCache.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ test('save with large cache outputs should fail', async () => {
4242
const createTarMock = jest.spyOn(tar, 'createTar')
4343

4444
const cacheSize = 6 * 1024 * 1024 * 1024 //~6GB, over the 5GB limit
45-
jest.spyOn(cacheUtils, 'getArchiveFileSize').mockReturnValue(cacheSize)
45+
jest.spyOn(cacheUtils, 'getArchiveFileSize').mockReturnValueOnce(cacheSize)
4646
const compression = CompressionMethod.Gzip
4747
const getCompressionMock = jest
4848
.spyOn(cacheUtils, 'getCompressionMethod')
@@ -108,15 +108,15 @@ test('save with server error should fail', async () => {
108108

109109
const saveCacheMock = jest
110110
.spyOn(cacheHttpClient, 'saveCache')
111-
.mockImplementationOnce(async () => {
111+
.mockImplementationOnce(() => {
112112
throw new Error('HTTP Error Occurred')
113113
})
114114
const compression = CompressionMethod.Zstd
115115
const getCompressionMock = jest
116116
.spyOn(cacheUtils, 'getCompressionMethod')
117117
.mockReturnValueOnce(Promise.resolve(compression))
118118

119-
await expect(await saveCache([filePath], primaryKey)).rejects.toThrowError(
119+
await expect(saveCache([filePath], primaryKey)).rejects.toThrowError(
120120
'HTTP Error Occurred'
121121
)
122122
expect(reserveCacheMock).toHaveBeenCalledTimes(1)

packages/cache/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cache/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "@actions/cache",
3-
"version": "0.0.0",
3+
"version": "1.0.0",
44
"preview": true,
5-
"description": "Actions artifact cache lib",
5+
"description": "Actions cache lib",
66
"keywords": [
77
"github",
88
"actions",

0 commit comments

Comments
 (0)