2023-12-23 17:49:17 +00:00
|
|
|
import test from "ava" // eslint-disable-line import/no-unresolved
|
2022-11-13 21:35:45 +00:00
|
|
|
|
2022-11-15 15:57:34 +00:00
|
|
|
import * as functions from "../src/functions"
|
2024-01-09 12:28:07 +00:00
|
|
|
import { NextflowRelease } from "../src/nextflow-release"
|
2022-11-14 03:22:12 +00:00
|
|
|
|
2023-12-23 17:49:17 +00:00
|
|
|
// 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 = {
|
|
|
|
versionNumber: version_number,
|
|
|
|
isEdge: is_edge,
|
|
|
|
binaryURL: `https://github.com/nextflow-io/nextflow/releases/download/${version_number}/nextflow`,
|
|
|
|
allBinaryURL: `https://github.com/nextflow-io/nextflow/releases/download/${version_number}/nextflow-${version_number.replace(
|
|
|
|
"v",
|
|
|
|
""
|
|
|
|
)}-all`
|
2022-11-14 02:29:05 +00:00
|
|
|
}
|
2023-12-23 17:49:17 +00:00
|
|
|
return release
|
|
|
|
}
|
2022-11-13 21:35:45 +00:00
|
|
|
|
2023-12-23 17:49:17 +00:00
|
|
|
// A mock set of Nextflow releases
|
2024-01-26 22:42:45 +00:00
|
|
|
async function* edge_is_newer(): AsyncGenerator<NextflowRelease> {
|
|
|
|
yield nf_release_gen("v23.09.1-edge")
|
|
|
|
yield nf_release_gen("v23.04.3")
|
|
|
|
yield nf_release_gen("v23.04.2")
|
|
|
|
}
|
|
|
|
|
|
|
|
async function* edge_is_older(): AsyncGenerator<NextflowRelease> {
|
|
|
|
yield nf_release_gen("v23.04.3")
|
|
|
|
yield nf_release_gen("v23.04.2")
|
|
|
|
yield nf_release_gen("v23.03.0-edge")
|
|
|
|
}
|
2022-11-13 05:00:23 +00:00
|
|
|
|
2023-12-23 17:49:17 +00:00
|
|
|
/*
|
|
|
|
The whole reason this action exists is to handle the cases where a final
|
|
|
|
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
|
|
|
|
'latest-everything' parameter can find the correct one regardless of whether
|
|
|
|
an "edge" release or a stable release is the true latest
|
|
|
|
*/
|
|
|
|
const release_filter_macro = test.macro(
|
|
|
|
async (
|
|
|
|
t,
|
|
|
|
input_version: string,
|
|
|
|
expected_version: string,
|
2024-01-26 22:42:45 +00:00
|
|
|
releases: AsyncGenerator<NextflowRelease>
|
2023-12-23 17:49:17 +00:00
|
|
|
) => {
|
|
|
|
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",
|
2024-01-26 22:42:45 +00:00
|
|
|
edge_is_newer()
|
2023-12-23 17:49:17 +00:00
|
|
|
)
|
|
|
|
test(
|
|
|
|
"Latest-everything install with older edge release",
|
|
|
|
release_filter_macro,
|
|
|
|
"latest-everything",
|
|
|
|
"v23.04.3",
|
2024-01-26 22:42:45 +00:00
|
|
|
edge_is_older()
|
2023-12-23 17:49:17 +00:00
|
|
|
)
|
|
|
|
test(
|
|
|
|
"Latest-edge install with newer edge release",
|
|
|
|
release_filter_macro,
|
|
|
|
"latest-edge",
|
|
|
|
"v23.09.1-edge",
|
2024-01-26 22:42:45 +00:00
|
|
|
edge_is_newer()
|
2023-12-23 17:49:17 +00:00
|
|
|
)
|
|
|
|
test(
|
|
|
|
"Latest-edge install with older edge release",
|
|
|
|
release_filter_macro,
|
|
|
|
"latest-edge",
|
|
|
|
"v23.03.0-edge",
|
2024-01-26 22:42:45 +00:00
|
|
|
edge_is_older()
|
2023-12-23 17:49:17 +00:00
|
|
|
)
|
|
|
|
test(
|
|
|
|
"Latest-stable install with newer edge release",
|
|
|
|
release_filter_macro,
|
|
|
|
"latest",
|
|
|
|
"v23.04.3",
|
2024-01-26 22:42:45 +00:00
|
|
|
edge_is_newer()
|
2023-12-23 17:49:17 +00:00
|
|
|
)
|
|
|
|
test(
|
|
|
|
"Latest-stable install with older edge release",
|
|
|
|
release_filter_macro,
|
|
|
|
"latest",
|
|
|
|
"v23.04.3",
|
2024-01-26 22:42:45 +00:00
|
|
|
edge_is_older()
|
2023-12-23 17:49:17 +00:00
|
|
|
)
|
|
|
|
test(
|
|
|
|
"Fully versioned tag release",
|
|
|
|
release_filter_macro,
|
|
|
|
"v23.04.2",
|
|
|
|
"v23.04.2",
|
2024-01-26 22:42:45 +00:00
|
|
|
edge_is_newer()
|
2023-12-23 17:49:17 +00:00
|
|
|
)
|
|
|
|
test(
|
|
|
|
"Partially versioned tag release",
|
|
|
|
release_filter_macro,
|
|
|
|
"v23.04",
|
|
|
|
"v23.04.3",
|
2024-01-26 22:42:45 +00:00
|
|
|
edge_is_newer()
|
2023-12-23 17:49:17 +00:00
|
|
|
)
|
2024-01-09 12:34:54 +00:00
|
|
|
|
|
|
|
test.todo("install_nextflow")
|