mirror of
https://github.com/MillironX/setup-nextflow.git
synced 2024-11-21 17:36:04 +00:00
test: Write tests for release_data function
This commit is contained in:
parent
c19a8b88ef
commit
93ff0f7ef2
4 changed files with 40 additions and 18 deletions
|
@ -39,6 +39,10 @@
|
|||
"source": [
|
||||
"src/**/*.ts"
|
||||
],
|
||||
"files": [
|
||||
"test/**/*.ts",
|
||||
"!test/utils.ts"
|
||||
],
|
||||
"concurrency": 1,
|
||||
"serial": true,
|
||||
"powerAssert": true
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import * as functions from '../src/functions'
|
||||
import {getToken} from './utils'
|
||||
import * as github from '@actions/github'
|
||||
import anyTest, {TestFn} from 'ava' // eslint-disable-line import/no-unresolved
|
||||
|
||||
|
@ -24,23 +25,5 @@ test('lastest_stable_release_data', async t => {
|
|||
t.is(result['tag_name'], 'v22.10.2')
|
||||
})
|
||||
|
||||
test('release_data', async t => {
|
||||
const result = await functions.release_data('v22.10.2', t.context['octokit'])
|
||||
t.is(result['tag_name'], 'v22.10.2')
|
||||
})
|
||||
|
||||
test.todo('nextflow_bin_url')
|
||||
test.todo('install_nextflow')
|
||||
|
||||
function getToken(first: boolean): string {
|
||||
const token = process.env['GITHUB_TOKEN'] || ''
|
||||
if (!token && first) {
|
||||
/* eslint-disable-next-line no-console */
|
||||
console.warn(
|
||||
'Skipping GitHub tests. Set $GITHUB_TOKEN to run REST client and GraphQL client tests'
|
||||
)
|
||||
first = false
|
||||
}
|
||||
|
||||
return token
|
||||
}
|
||||
|
|
23
test/releasedata.ts
Normal file
23
test/releasedata.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
import * as github from '@actions/github'
|
||||
import {release_data} from '../src/functions'
|
||||
import {getToken} from './utils'
|
||||
import anyTest, {TestFn} from 'ava' // eslint-disable-line import/no-unresolved
|
||||
|
||||
const test = anyTest as TestFn<{foo: string}>
|
||||
|
||||
test.before(t => {
|
||||
const first = true
|
||||
const current_token = getToken(first)
|
||||
t.context = {token: current_token}
|
||||
t.context = {octokit: github.getOctokit(current_token)}
|
||||
})
|
||||
|
||||
const macro = test.macro(async (t, version: string, expected: string) => {
|
||||
const result = await release_data(version, t.context['octokit'])
|
||||
t.is(result['tag_name'], expected)
|
||||
})
|
||||
|
||||
test('hard version', macro, 'v22.10.2', 'v22.10.2')
|
||||
test('latest-stable', macro, 'latest-stable', 'v22.10.2')
|
||||
test('latest-edge', macro, 'latest-edge', 'v22.09.7-edge')
|
||||
test('latest-everything', macro, 'latest-everything', 'v22.10.2')
|
12
test/utils.ts
Normal file
12
test/utils.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
export function getToken(first: boolean): string {
|
||||
const token = process.env['GITHUB_TOKEN'] || ''
|
||||
if (!token && first) {
|
||||
/* eslint-disable-next-line no-console */
|
||||
console.warn(
|
||||
'Skipping GitHub tests. Set $GITHUB_TOKEN to run REST client and GraphQL client tests'
|
||||
)
|
||||
first = false
|
||||
}
|
||||
|
||||
return token
|
||||
}
|
Loading…
Reference in a new issue