mirror of
https://github.com/DeLaGuardo/setup-clojure.git
synced 2024-12-27 16:41:06 +08:00
83 lines
2.1 KiB
TypeScript
83 lines
2.1 KiB
TypeScript
import io = require('@actions/io');
|
|
import os = require('os');
|
|
import fs = require('fs');
|
|
import path = require('path');
|
|
|
|
const toolDir = path.join(__dirname, 'runner', 'tools', 'tdeps');
|
|
const tempDir = path.join(__dirname, 'runner', 'temp', 'tdeps');
|
|
const IS_WINDOWS = process.platform === 'win32';
|
|
|
|
process.env['RUNNER_TOOL_CACHE'] = toolDir;
|
|
process.env['RUNNER_TEMP'] = tempDir;
|
|
import * as tdeps from '../src/tdeps';
|
|
|
|
describe('tdeps tests', () => {
|
|
beforeAll(async () => {
|
|
await io.rmRF(toolDir);
|
|
await io.rmRF(tempDir);
|
|
}, 300000);
|
|
|
|
afterAll(async () => {
|
|
try {
|
|
await io.rmRF(toolDir);
|
|
await io.rmRF(tempDir);
|
|
} catch {
|
|
console.log('Failed to remove test directories');
|
|
}
|
|
}, 100000);
|
|
|
|
it('Throws if invalid version', async () => {
|
|
let thrown = false;
|
|
try {
|
|
await tdeps.setup('1000');
|
|
} catch {
|
|
thrown = true;
|
|
}
|
|
expect(thrown).toBe(true);
|
|
});
|
|
|
|
it('Install clojure tools deps with normal version', async () => {
|
|
await tdeps.setup('1.10.1.469');
|
|
const clojureDir = path.join(
|
|
toolDir,
|
|
'ClojureToolsDeps',
|
|
'1.10.1-469',
|
|
os.arch()
|
|
);
|
|
|
|
expect(fs.existsSync(`${clojureDir}.complete`)).toBe(true);
|
|
expect(fs.existsSync(path.join(clojureDir, 'bin', 'clojure'))).toBe(true);
|
|
}, 100000);
|
|
|
|
it('Uses version of clojure tools-deps installed in cache', async () => {
|
|
const clojureDir: string = path.join(
|
|
toolDir,
|
|
'ClojureToolsDeps',
|
|
'1.10.1-469',
|
|
os.arch()
|
|
);
|
|
await io.mkdirP(clojureDir);
|
|
fs.writeFileSync(`${clojureDir}.complete`, 'hello');
|
|
await tdeps.setup('1.10.1.469');
|
|
return;
|
|
});
|
|
|
|
it('Doesnt use version of clojure that was only partially installed in cache', async () => {
|
|
const clojureDir: string = path.join(
|
|
toolDir,
|
|
'ClojureToolsDeps',
|
|
'1.10.1-469',
|
|
os.arch()
|
|
);
|
|
await io.mkdirP(clojureDir);
|
|
let thrown = false;
|
|
try {
|
|
await tdeps.setup('1000');
|
|
} catch {
|
|
thrown = true;
|
|
}
|
|
expect(thrown).toBe(true);
|
|
return;
|
|
});
|
|
});
|