mirror of
https://github.com/MillironX/setup-nextflow.git
synced 2024-11-21 09:26:04 +00:00
test: Add tests for Nextflow release version resolver
This commit is contained in:
parent
d86e286349
commit
d734edd2bc
1 changed files with 95 additions and 0 deletions
95
test/functions.ts
Normal file
95
test/functions.ts
Normal file
|
@ -0,0 +1,95 @@
|
|||
import test from "ava"
|
||||
|
||||
import { get_nextflow_release } from "../src/functions"
|
||||
import { NextflowRelease } from "../src/nextflow-release"
|
||||
|
||||
// The Nextflow releases we are going to use for testing follow a regular
|
||||
// pattern: create a mock function to bootstrap some test data without repeating
|
||||
// ourselves
|
||||
function nf_release_gen(version_number: string): NextflowRelease {
|
||||
const is_edge = version_number.endsWith("-edge")
|
||||
const release: NextflowRelease = {
|
||||
version: version_number,
|
||||
isEdge: is_edge,
|
||||
downloadUrl: `https://github.com/nextflow-io/nextflow/releases/download/${version_number}/nextflow`,
|
||||
downloadUrlAll: `https://github.com/nextflow-io/nextflow/releases/download/${version_number}/nextflow-${version_number.replace(
|
||||
"v",
|
||||
""
|
||||
)}-all`
|
||||
}
|
||||
return release
|
||||
}
|
||||
|
||||
const release_test_macro = test.macro(
|
||||
async (
|
||||
t,
|
||||
input_version: string,
|
||||
expected_version: string,
|
||||
is_edge_older: Boolean
|
||||
) => {
|
||||
const releases_set = [
|
||||
nf_release_gen("v21.05.1-edge"),
|
||||
nf_release_gen("v21.05.0-edge"),
|
||||
nf_release_gen("v21.04.2"),
|
||||
nf_release_gen("v21.04.1"),
|
||||
nf_release_gen("v21.04.0"),
|
||||
nf_release_gen("v21.03.0-edge")
|
||||
]
|
||||
const release_filtered = releases_set.splice(is_edge_older ? 2 : 0)
|
||||
const matched_release = await get_nextflow_release(
|
||||
input_version,
|
||||
release_filtered
|
||||
)
|
||||
t.is(matched_release.version, expected_version)
|
||||
}
|
||||
)
|
||||
|
||||
test(
|
||||
"Major and minor version only (edge newer)",
|
||||
release_test_macro,
|
||||
"v21.04",
|
||||
"v21.04.2",
|
||||
false
|
||||
)
|
||||
test(
|
||||
"Major and minor version only (edge older)",
|
||||
release_test_macro,
|
||||
"v21.04",
|
||||
"v21.04.2",
|
||||
true
|
||||
)
|
||||
test(
|
||||
"Major, minor, and patch version: latest patch (edge newer)",
|
||||
release_test_macro,
|
||||
"v21.04.2",
|
||||
"v21.04.2",
|
||||
false
|
||||
)
|
||||
test(
|
||||
"Major, minor, and patch version: latest patch (edge older)",
|
||||
release_test_macro,
|
||||
"v21.04.2",
|
||||
"v21.04.2",
|
||||
true
|
||||
)
|
||||
test(
|
||||
"Major, minor, and patch version: older patch (edge newer)",
|
||||
release_test_macro,
|
||||
"v21.04.1",
|
||||
"v21.04.1",
|
||||
false
|
||||
)
|
||||
test(
|
||||
"Major, minor, and patch version: older patch (edge older)",
|
||||
release_test_macro,
|
||||
"v21.04.1",
|
||||
"v21.04.1",
|
||||
true
|
||||
)
|
||||
test(
|
||||
"Edge release",
|
||||
release_test_macro,
|
||||
"v21.03.0-edge",
|
||||
"v21.03.0-edge",
|
||||
false
|
||||
)
|
Loading…
Reference in a new issue