1
0
Fork 0

review comments

pull/1028/head
Shubham Tiwari 2022-03-25 00:02:17 +05:30
parent 71b35793b1
commit 2487627b27
7 changed files with 20 additions and 22 deletions

View File

@ -51,5 +51,5 @@
### 1.0.10
- Update `lockfileVersion` to `v2` in `package-lock.json [#1022](https://github.com/actions/toolkit/pull/1022)
### 1.0.11
### 2.0.0
- Added support to check if Actions cache service feature is available or not [#1028](https://github.com/actions/toolkit/pull/1028)

15
packages/cache/__tests__/cache.test.ts vendored Normal file
View File

@ -0,0 +1,15 @@
import * as cache from '../src/cache'
test('isFeatureAvailable returns true if server url is set', () => {
try {
process.env['ACTIONS_CACHE_URL'] = 'http://cache.com'
expect(cache.isFeatureAvailable()).toBe(true)
} finally {
delete process.env['ACTIONS_CACHE_URL']
}
})
test('isFeatureAvailable returns false if server url is not set', () => {
expect(cache.isFeatureAvailable()).toBe(false)
})

View File

@ -32,16 +32,3 @@ test('assertDefined throws if undefined', () => {
test('assertDefined returns value', () => {
expect(cacheUtils.assertDefined('test', 5)).toBe(5)
})
test('isFeatureAvailable returns true if server url is set', () => {
try {
process.env['ACTIONS_CACHE_URL'] = 'http://cache.com'
expect(cacheUtils.isFeatureAvailable()).toBe(true)
} finally {
delete process.env['ACTIONS_CACHE_URL']
}
})
test('isFeatureAvailable returns false if server url is not set', () => {
expect(cacheUtils.isFeatureAvailable()).toBe(false)
})

4
packages/cache/package-lock.json generated vendored
View File

@ -1,12 +1,12 @@
{
"name": "@actions/cache",
"version": "1.0.11",
"version": "2.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@actions/cache",
"version": "1.0.11",
"version": "2.0.0",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.2.6",

View File

@ -1,6 +1,6 @@
{
"name": "@actions/cache",
"version": "1.0.11",
"version": "2.0.0",
"preview": true,
"description": "Actions cache lib",
"keywords": [

View File

@ -50,7 +50,7 @@ function checkKey(key: string): void {
*/
export function isFeatureAvailable(): boolean {
return utils.isFeatureAvailable()
return !!process.env['ACTIONS_CACHE_URL']
}
/**

View File

@ -123,7 +123,3 @@ export function assertDefined<T>(name: string, value?: T): T {
return value
}
export function isFeatureAvailable(): boolean {
return !!process.env['ACTIONS_CACHE_URL']
}