Skip to content

Commit

Permalink
drop Math.random usage
Browse files Browse the repository at this point in the history
  • Loading branch information
lukka committed Dec 6, 2024
1 parent 7a8ffdb commit 266bbd5
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion __tests__/action_failed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as core from '@actions/core';
import * as getcmake from '../src/get-cmake';
import path = require('path');
import { ToolsGetter } from '../src/get-cmake';
import * as crypto from 'crypto';

// 10 minutes
jest.setTimeout(10 * 60 * 1000)
Expand Down Expand Up @@ -36,7 +37,7 @@ var coreError = jest.spyOn(core, 'error').mockImplementation(() => {});
var toolsCacheDir = jest.spyOn(toolcache, 'cacheDir');

test('testing get-cmake action failure', async () => {
const testId = Math.random();
const testId = crypto.randomBytes(16).toString('hex');
process.exitCode
process.env.RUNNER_TEMP = path.join(os.tmpdir(), `${testId}`);
process.env.RUNNER_TOOL_CACHE = path.join(os.tmpdir(), `${testId}-cache`);
Expand Down
7 changes: 4 additions & 3 deletions __tests__/action_succeeded.localcloud.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// SPDX short identifier: MIT

import * as os from 'os';
import * as crypto from 'crypto';
import * as toolcache from '@actions/tool-cache';
import * as core from '@actions/core';
import * as path from 'path'
Expand Down Expand Up @@ -46,7 +47,7 @@ var toolsCacheDir = jest.spyOn(toolcache, 'cacheDir');
var toolsFind = jest.spyOn(toolcache, 'find');

test('testing get-cmake action success with cloud/local cache enabled', async () => {
const testId = Math.random();
const testId = crypto.randomBytes(16).toString('hex');
process.env.RUNNER_TEMP = path.join(os.tmpdir(), `${testId}`);
process.env.RUNNER_TOOL_CACHE = path.join(os.tmpdir(), `${testId}-cache`);

Expand Down Expand Up @@ -78,7 +79,7 @@ test('testing get-cmake action success with cloud/local cache enabled', async ()
});

test('testing get-cmake action success with local or cloud cache hits', async () => {
const testId = Math.random();
const testId = crypto.randomBytes(16).toString('hex');
process.env.RUNNER_TEMP = path.join(os.tmpdir(), `${testId}`);
process.env.RUNNER_TOOL_CACHE = path.join(os.tmpdir(), `${testId}-cache`);

Expand Down Expand Up @@ -121,7 +122,7 @@ test('testing get-cmake action store and restore local cache', async () => {
toolsCacheDir.mockRestore();
toolsFind.mockRestore();

const testId = Math.random();
const testId = crypto.randomBytes(16).toString('hex');
process.env.RUNNER_TEMP = path.join(os.tmpdir(), `${testId}`);
process.env.RUNNER_TOOL_CACHE = path.join(os.tmpdir(), `${testId}-cache`);
let downloadMock = undefined;
Expand Down
3 changes: 2 additions & 1 deletion __tests__/cachehit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as os from 'os';
import { ToolsGetter } from '../src/get-cmake';
import * as cache from '@actions/cache';
import path = require('path');
import * as crypto from 'crypto';

// 10 minutes
jest.setTimeout(10 * 60 * 1000)
Expand All @@ -24,7 +25,7 @@ const cacheRestoreCache = jest.spyOn(cache, 'restoreCache').mockImplementation((
const addToolsToPath = jest.spyOn(ToolsGetter.prototype as any, 'addToolsToPath').mockResolvedValue(0);

test('testing get-cmake with cache-hit...', async () => {
const testId = Math.random();
const testId = crypto.randomBytes(16).toString('hex');
process.env.RUNNER_TEMP = path.join(os.tmpdir(), `${testId}`);

const getter: ToolsGetter = new ToolsGetter();
Expand Down
3 changes: 2 additions & 1 deletion __tests__/cachemiss.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ToolsGetter } from '../src/get-cmake';
import * as cache from '@actions/cache';
import * as core from '@actions/core';
import path = require('path');
import * as crypto from 'crypto';

// 10 minutes
jest.setTimeout(10 * 60 * 1000)
Expand All @@ -27,7 +28,7 @@ const cacheRestoreCache = jest.spyOn(cache, 'restoreCache').mockImplementation((
const addToolsToPath = jest.spyOn(ToolsGetter.prototype as any, 'addToolsToPath').mockResolvedValue(0);

test('testing get-cmake with cache-miss...', async () => {
const testId = Math.random();
const testId = crypto.randomBytes(16).toString('hex');
process.env.RUNNER_TEMP = path.join(os.tmpdir(), `${testId}`);
const getter: ToolsGetter = new ToolsGetter();
await getter.run();
Expand Down
3 changes: 2 additions & 1 deletion __tests__/cacherestorefailure.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as os from 'os';
import { ToolsGetter } from '../src/get-cmake';
import * as cache from '@actions/cache';
import path = require('path');
import * as crypto from 'crypto';

// 10 minutes
jest.setTimeout(10 * 60 * 1000)
Expand All @@ -24,7 +25,7 @@ jest.spyOn(cache, 'restoreCache').mockImplementation(() => {
const addToolsToPath = jest.spyOn(ToolsGetter.prototype as any, 'addToolsToPath').mockResolvedValue(0);

test('testing get-cmake with restoreCache failure', async () => {
const testId = Math.random();
const testId = crypto.randomBytes(16).toString('hex');
process.env.RUNNER_TEMP = path.join(os.tmpdir(), `${testId}`);

const getter: ToolsGetter = new ToolsGetter();
Expand Down

0 comments on commit 266bbd5

Please sign in to comment.