mirror of
https://github.com/MillironX/setup-nextflow.git
synced 2024-11-23 18:09:55 +00:00
test: Refactor API tests to work with combined functions
Now that we are lazy-loading the API pages, OctokitWrapper is handling the conversion to NextflowRelease in one function call. This means we can't test the API schema. That should be fine as we pinned the API version. We can test that the resulting objects for validity, so do that.
This commit is contained in:
parent
67a9c84bd7
commit
da56dbefc9
1 changed files with 61 additions and 16 deletions
|
@ -23,22 +23,67 @@ test.before(t => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const exists_macro = test.macro(async (t, object_name: string) => {
|
async function get_latest_release(
|
||||||
const all_releases = await all_nf_release_data(t.context.octokit)
|
octokit: InstanceType<typeof GitHub>,
|
||||||
const first_release = all_releases[0]
|
use_latest_api: boolean
|
||||||
t.assert(first_release.hasOwnProperty(object_name))
|
): Promise<NextflowRelease> {
|
||||||
})
|
if (use_latest_api) {
|
||||||
|
return await pull_latest_stable_release(octokit)
|
||||||
|
} else {
|
||||||
|
const all_releases = pull_releases(octokit)
|
||||||
|
const first_response = await all_releases.next()
|
||||||
|
const first_release = first_response.value
|
||||||
|
? first_response.value
|
||||||
|
: ({} as NextflowRelease)
|
||||||
|
return first_release
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
test("OctoKit returns tag", exists_macro, "tag_name")
|
const version_macro = test.macro(
|
||||||
test("Octokit returns prerelease", exists_macro, "prerelease")
|
async (t, object_name: string, use_latest_api: boolean) => {
|
||||||
test("Octokit returns assets", exists_macro, "assets")
|
const latest_release = await get_latest_release(
|
||||||
|
t.context.octokit,
|
||||||
|
use_latest_api
|
||||||
|
)
|
||||||
|
t.assert(latest_release[object_name])
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
const binary_url_macro = test.macro(async (t, get_all: boolean) => {
|
test(
|
||||||
const all_releases = await all_nf_release_data(t.context.octokit)
|
"OctoKit iterator returns semver-parsable version number",
|
||||||
const first_release = all_releases[0]
|
version_macro,
|
||||||
const url = nextflow_bin_url(first_release, get_all)
|
"versionNumber",
|
||||||
t.notThrows(() => new URL(url))
|
false
|
||||||
})
|
)
|
||||||
|
test(
|
||||||
|
"OctoKit latest API returns semver-parable version number",
|
||||||
|
version_macro,
|
||||||
|
"versionNumber",
|
||||||
|
true
|
||||||
|
)
|
||||||
|
|
||||||
test("Nextflow binary URL valid", binary_url_macro, false)
|
const binary_url_macro = test.macro(
|
||||||
test("Nextflow 'all' binary URL valid", binary_url_macro, true)
|
async (t, get_all: boolean, use_latest_api: boolean) => {
|
||||||
|
const latest_release = await get_latest_release(
|
||||||
|
t.context.octokit,
|
||||||
|
use_latest_api
|
||||||
|
)
|
||||||
|
const url = get_all ? latest_release.allBinaryURL : latest_release.binaryURL
|
||||||
|
t.notThrows(() => new URL(url))
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
test("Nextflow binary URL from iterator valid", binary_url_macro, false, false)
|
||||||
|
test("Nextflow binary URL from latest API valid", binary_url_macro, false, true)
|
||||||
|
test(
|
||||||
|
"Nextflow all binary URL from iterator valid",
|
||||||
|
binary_url_macro,
|
||||||
|
true,
|
||||||
|
false
|
||||||
|
)
|
||||||
|
test(
|
||||||
|
"Nextflow all binary URL from latest API valid",
|
||||||
|
binary_url_macro,
|
||||||
|
true,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in a new issue