-
Notifications
You must be signed in to change notification settings - Fork 0
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
Alex Kalyvitis
committed
Jun 18, 2020
1 parent
3f2a60b
commit ff8fe44
Showing
6 changed files
with
147 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import test from 'ava'; | ||
import * as path from 'path'; | ||
import * as toolcache from '@actions/tool-cache'; | ||
import * as util from './util'; | ||
import nock from 'nock'; | ||
|
||
import * as setupTools from './setup-tools'; | ||
|
||
test('download codeql bundle cache', async t => { | ||
|
||
await util.withTmpDir(async tmpDir => { | ||
|
||
process.env['GITHUB_WORKSPACE'] = tmpDir; | ||
|
||
process.env['RUNNER_TEMP'] = path.join(tmpDir, 'temp'); | ||
process.env['RUNNER_TOOL_CACHE'] = path.join(tmpDir, 'cache'); | ||
|
||
const versions = ['20200601', '20200610']; | ||
|
||
for (let i = 0; i < versions.length; i++) { | ||
const version = versions[i]; | ||
|
||
nock('https://example.com') | ||
.get(`/download/codeql-bundle-${version}/codeql-bundle.tar.gz`) | ||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`)); | ||
|
||
|
||
process.env['INPUT_TOOLS'] = `https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`; | ||
|
||
await setupTools.setupCodeQL(); | ||
|
||
t.assert(toolcache.find('CodeQL', `0.0.0-${version}`)); | ||
} | ||
|
||
const cachedVersions = toolcache.findAllVersions('CodeQL'); | ||
|
||
t.is(cachedVersions.length, 2); | ||
}); | ||
}) | ||
|
||
test('parse codeql bundle url version', t => { | ||
|
||
const tests = { | ||
'20200601': '0.0.0-20200601', | ||
'20200601.0': '0.0.0-20200601.0', | ||
'20200601.0.0': '20200601.0.0', | ||
'1.2.3': '1.2.3', | ||
'1.2.3-alpha': '1.2.3-alpha', | ||
'1.2.3-beta.1': '1.2.3-beta.1', | ||
}; | ||
|
||
for (const version in tests) { | ||
|
||
const expectedVersion = tests[version]; | ||
const url = `https://github.com/.../codeql-bundle-${version}/...`; | ||
|
||
try { | ||
const parsedVersion = setupTools.getCodeQLURLVersion(url); | ||
t.assert(parsedVersion, expectedVersion); | ||
} catch (e) { | ||
t.fail(e.message); | ||
} | ||
} | ||
}); |
Binary file not shown.