mirror of
https://github.com/MillironX/setup-nextflow.git
synced 2024-11-21 17:36:04 +00:00
test: Update version checking tests
This commit is contained in:
parent
85718639f5
commit
f65da33a7d
1 changed files with 105 additions and 29 deletions
|
@ -1,37 +1,113 @@
|
||||||
import * as github from "@actions/github"
|
import test from "ava" // eslint-disable-line import/no-unresolved
|
||||||
import { GitHub } from "@actions/github/lib/utils"
|
|
||||||
import anyTest, { TestFn } from "ava" // eslint-disable-line import/no-unresolved
|
|
||||||
|
|
||||||
import * as functions from "../src/functions"
|
import * as functions from "../src/functions"
|
||||||
import { getReleaseTag, getToken } from "./utils"
|
import { NextflowRelease } from "../src/NextflowRelease"
|
||||||
|
|
||||||
const test = anyTest as TestFn<{
|
// The Nextflow releases we are going to use for testing follow a regular
|
||||||
token: string
|
// pattern: create a mock function to bootstrap some test data without repeating
|
||||||
octokit: InstanceType<typeof GitHub>
|
// ourselves
|
||||||
}>
|
function nf_release_gen(version_number: string): NextflowRelease {
|
||||||
|
const is_edge = version_number.endsWith("-edge")
|
||||||
test.before(t => {
|
const release: NextflowRelease = {
|
||||||
const first = true
|
versionNumber: version_number,
|
||||||
const current_token = getToken(first)
|
isEdge: is_edge,
|
||||||
t.context = {
|
binaryURL: `https://github.com/nextflow-io/nextflow/releases/download/${version_number}/nextflow`,
|
||||||
token: current_token,
|
allBinaryURL: `https://github.com/nextflow-io/nextflow/releases/download/${version_number}/nextflow-${version_number.replace(
|
||||||
octokit: github.getOctokit(current_token)
|
"v",
|
||||||
|
""
|
||||||
|
)}-all`
|
||||||
}
|
}
|
||||||
})
|
return release
|
||||||
|
}
|
||||||
|
|
||||||
test("all_nf_releases", async t => {
|
// A mock set of Nextflow releases
|
||||||
const result = await functions.all_nf_releases(t.context["octokit"])
|
const edge_is_newer = [
|
||||||
t.is(typeof result, "object")
|
nf_release_gen("v23.09.1-edge"),
|
||||||
})
|
nf_release_gen("v23.04.3"),
|
||||||
|
nf_release_gen("v23.04.2")
|
||||||
|
]
|
||||||
|
const edge_is_older = [
|
||||||
|
nf_release_gen("v23.04.3"),
|
||||||
|
nf_release_gen("v23.04.2"),
|
||||||
|
nf_release_gen("v23.03.0-edge")
|
||||||
|
]
|
||||||
|
|
||||||
test("lastest_stable_release_data", async t => {
|
/*
|
||||||
const result = await functions.latest_stable_release_data(
|
The whole reason this action exists is to handle the cases where a final
|
||||||
t.context["octokit"]
|
release is the "bleeding edge" release, rather than the "edge" release, even
|
||||||
)
|
though that's what the name would imply. Therefore, we need to test that the
|
||||||
t.is(typeof result, "object")
|
'latest-everything' parameter can find the correct one regardless of whether
|
||||||
const expected = await getReleaseTag("nextflow-io/nextflow", false)
|
an "edge" release or a stable release is the true latest
|
||||||
t.is(result["tag_name"], expected)
|
*/
|
||||||
})
|
const release_filter_macro = test.macro(
|
||||||
|
async (
|
||||||
|
t,
|
||||||
|
input_version: string,
|
||||||
|
expected_version: string,
|
||||||
|
releases: NextflowRelease[]
|
||||||
|
) => {
|
||||||
|
const matched_release = await functions.get_nextflow_release(
|
||||||
|
input_version,
|
||||||
|
releases
|
||||||
|
)
|
||||||
|
t.is(matched_release.versionNumber, expected_version)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
test(
|
||||||
|
"Latest-everything install with newer edge release",
|
||||||
|
release_filter_macro,
|
||||||
|
"latest-everything",
|
||||||
|
"v23.09.1-edge",
|
||||||
|
edge_is_newer
|
||||||
|
)
|
||||||
|
test(
|
||||||
|
"Latest-everything install with older edge release",
|
||||||
|
release_filter_macro,
|
||||||
|
"latest-everything",
|
||||||
|
"v23.04.3",
|
||||||
|
edge_is_older
|
||||||
|
)
|
||||||
|
test(
|
||||||
|
"Latest-edge install with newer edge release",
|
||||||
|
release_filter_macro,
|
||||||
|
"latest-edge",
|
||||||
|
"v23.09.1-edge",
|
||||||
|
edge_is_newer
|
||||||
|
)
|
||||||
|
test(
|
||||||
|
"Latest-edge install with older edge release",
|
||||||
|
release_filter_macro,
|
||||||
|
"latest-edge",
|
||||||
|
"v23.03.0-edge",
|
||||||
|
edge_is_older
|
||||||
|
)
|
||||||
|
test(
|
||||||
|
"Latest-stable install with newer edge release",
|
||||||
|
release_filter_macro,
|
||||||
|
"latest",
|
||||||
|
"v23.04.3",
|
||||||
|
edge_is_newer
|
||||||
|
)
|
||||||
|
test(
|
||||||
|
"Latest-stable install with older edge release",
|
||||||
|
release_filter_macro,
|
||||||
|
"latest",
|
||||||
|
"v23.04.3",
|
||||||
|
edge_is_older
|
||||||
|
)
|
||||||
|
test(
|
||||||
|
"Fully versioned tag release",
|
||||||
|
release_filter_macro,
|
||||||
|
"v23.04.2",
|
||||||
|
"v23.04.2",
|
||||||
|
edge_is_newer
|
||||||
|
)
|
||||||
|
test(
|
||||||
|
"Partially versioned tag release",
|
||||||
|
release_filter_macro,
|
||||||
|
"v23.04",
|
||||||
|
"v23.04.3",
|
||||||
|
edge_is_newer
|
||||||
|
)
|
||||||
|
|
||||||
test.todo("nextflow_bin_url")
|
|
||||||
test.todo("install_nextflow")
|
test.todo("install_nextflow")
|
||||||
|
|
Loading…
Reference in a new issue