generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
155078e
commit b03ae87
Showing
5 changed files
with
189 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,103 +1,119 @@ | ||
import io = require('@actions/io'); | ||
import fs = require('fs'); | ||
import os = require('os'); | ||
import path = require('path'); | ||
import io = require('@actions/io') | ||
import fs = require('fs') | ||
import os = require('os') | ||
import path = require('path') | ||
|
||
const toolDir = path.join(__dirname, 'runner', 'tools'); | ||
const tempDir = path.join(__dirname, 'runner', 'temp'); | ||
const toolDir = path.join(__dirname, 'runner', 'tools') | ||
const tempDir = path.join(__dirname, 'runner', 'temp') | ||
|
||
process.env['RUNNER_TOOL_CACHE'] = toolDir; | ||
process.env['RUNNER_TEMP'] = tempDir; | ||
process.env['RUNNER_TOOL_CACHE'] = toolDir | ||
process.env['RUNNER_TEMP'] = tempDir | ||
|
||
import * as installer from '../src/installer'; | ||
import * as installer from '../src/installer' | ||
|
||
const IS_WINDOWS = os.platform() === 'win32'; | ||
const IS_WINDOWS = os.platform() === 'win32' | ||
|
||
describe('installer tests', () => { | ||
beforeAll(async () => { | ||
await io.rmRF(toolDir); | ||
await io.rmRF(tempDir); | ||
}, 100000); | ||
await io.rmRF(toolDir) | ||
await io.rmRF(tempDir) | ||
}, 100000) | ||
|
||
afterAll(async () => { | ||
await io.rmRF(toolDir); | ||
await io.rmRF(tempDir); | ||
}, 100000); | ||
await io.rmRF(toolDir) | ||
await io.rmRF(tempDir) | ||
}, 100000) | ||
|
||
it('Acquires kustomize version 3.2.0 successfully', async () => { | ||
await installer.getKustomize('3.2.0'); | ||
const kustomizeDir = path.join(toolDir, 'kustomize', '3.2.0', os.arch()); | ||
await installer.getKustomize('3.2.0') | ||
const kustomizeDir = path.join(toolDir, 'kustomize', '3.2.0', os.arch()) | ||
|
||
expect(fs.existsSync(`${kustomizeDir}.complete`)).toBe(true); | ||
expect(fs.existsSync(`${kustomizeDir}.complete`)).toBe(true) | ||
|
||
if (IS_WINDOWS) { | ||
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize.exe'))).toBe(true); | ||
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize.exe'))).toBe(true) | ||
} else { | ||
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize'))).toBe(true); | ||
expect(() => fs.accessSync(path.join(kustomizeDir, 'kustomize'), fs.constants.X_OK)).not.toThrow() | ||
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize'))).toBe(true) | ||
expect(() => | ||
fs.accessSync(path.join(kustomizeDir, 'kustomize'), fs.constants.X_OK) | ||
).not.toThrow() | ||
} | ||
}, 100000); | ||
}, 100000) | ||
|
||
it ('Acquires kustomize version 3.2.1 successfully', async () => { | ||
await installer.getKustomize('3.2.1'); | ||
const kustomizeDir = path.join(toolDir, 'kustomize', '3.2.1', os.arch()); | ||
it('Acquires kustomize version 3.2.1 successfully', async () => { | ||
await installer.getKustomize('3.2.1') | ||
const kustomizeDir = path.join(toolDir, 'kustomize', '3.2.1', os.arch()) | ||
|
||
expect(fs.existsSync(`${kustomizeDir}.complete`)).toBe(true); | ||
expect(fs.existsSync(`${kustomizeDir}.complete`)).toBe(true) | ||
|
||
if (IS_WINDOWS) { | ||
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize.exe'))).toBe(true); | ||
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize.exe'))).toBe(true) | ||
} else { | ||
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize'))).toBe(true); | ||
expect(() => fs.accessSync(path.join(kustomizeDir, 'kustomize'), fs.constants.X_OK)).not.toThrow() | ||
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize'))).toBe(true) | ||
expect(() => | ||
fs.accessSync(path.join(kustomizeDir, 'kustomize'), fs.constants.X_OK) | ||
).not.toThrow() | ||
} | ||
}, 100000) | ||
|
||
it ('Acquires kustomize version 3.3.0 successfully', async () => { | ||
await installer.getKustomize('3.3.0'); | ||
const kustomizeDir = path.join(toolDir, 'kustomize', '3.3.0', os.arch()); | ||
it('Acquires kustomize version 3.3.0 successfully', async () => { | ||
await installer.getKustomize('3.3.0') | ||
const kustomizeDir = path.join(toolDir, 'kustomize', '3.3.0', os.arch()) | ||
|
||
expect(fs.existsSync(`${kustomizeDir}.complete`)).toBe(true); | ||
expect(fs.existsSync(`${kustomizeDir}.complete`)).toBe(true) | ||
|
||
if (IS_WINDOWS) { | ||
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize.exe'))).toBe(true); | ||
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize.exe'))).toBe(true) | ||
} else { | ||
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize'))).toBe(true); | ||
expect(() => fs.accessSync(path.join(kustomizeDir, 'kustomize'), fs.constants.X_OK)).not.toThrow() | ||
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize'))).toBe(true) | ||
expect(() => | ||
fs.accessSync(path.join(kustomizeDir, 'kustomize'), fs.constants.X_OK) | ||
).not.toThrow() | ||
} | ||
}, 100000) | ||
|
||
it('Throws if no location contains correct kustomize version', async () => { | ||
let thrown = false; | ||
let thrown = false | ||
|
||
try { | ||
await installer.getKustomize('1000'); | ||
await installer.getKustomize('1000') | ||
} catch { | ||
thrown = true; | ||
thrown = true | ||
} | ||
|
||
expect(thrown).toBe(true); | ||
}); | ||
expect(thrown).toBe(true) | ||
}) | ||
|
||
it('Uses version of kustomize installed in cache', async () => { | ||
const kustomizeDir: string = path.join(toolDir, 'kustomize', '3.2.0', os.arch()); | ||
const kustomizeDir: string = path.join( | ||
toolDir, | ||
'kustomize', | ||
'3.2.0', | ||
os.arch() | ||
) | ||
|
||
await io.mkdirP(kustomizeDir); | ||
await io.mkdirP(kustomizeDir) | ||
|
||
fs.writeFileSync(`${kustomizeDir}.complete`, 'hello'); | ||
fs.writeFileSync(`${kustomizeDir}.complete`, 'hello') | ||
|
||
await installer.getKustomize('3.2.0'); | ||
await installer.getKustomize('3.2.0') | ||
|
||
return; | ||
}); | ||
return | ||
}) | ||
|
||
it('Resolves semantic versions of kustomize installed in cache', async () => { | ||
const kustomizeDir: string = path.join(toolDir, 'kustomize', '3.0.0', os.arch()); | ||
const kustomizeDir: string = path.join( | ||
toolDir, | ||
'kustomize', | ||
'3.0.0', | ||
os.arch() | ||
) | ||
|
||
await io.mkdirP(kustomizeDir); | ||
await io.mkdirP(kustomizeDir) | ||
|
||
fs.writeFileSync(`${kustomizeDir}.complete`, 'hello'); | ||
fs.writeFileSync(`${kustomizeDir}.complete`, 'hello') | ||
|
||
await installer.getKustomize('3.0.0'); | ||
await installer.getKustomize('3.0'); | ||
}); | ||
}); | ||
await installer.getKustomize('3.0.0') | ||
await installer.getKustomize('3.0') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.