test: Update testing framework to support iterators

This commit is contained in:
Thomas A. Christensen II 2024-01-26 16:42:45 -06:00
parent 737834224d
commit 91ef9fb65a
2 changed files with 25 additions and 21 deletions

View file

@ -21,16 +21,17 @@ function nf_release_gen(version_number: string): NextflowRelease {
}
// A mock set of Nextflow releases
const edge_is_newer = [
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")
]
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")
}
/*
The whole reason this action exists is to handle the cases where a final
@ -44,7 +45,7 @@ const release_filter_macro = test.macro(
t,
input_version: string,
expected_version: string,
releases: NextflowRelease[]
releases: AsyncGenerator<NextflowRelease>
) => {
const matched_release = await functions.get_nextflow_release(
input_version,
@ -58,56 +59,56 @@ test(
release_filter_macro,
"latest-everything",
"v23.09.1-edge",
edge_is_newer
edge_is_newer()
)
test(
"Latest-everything install with older edge release",
release_filter_macro,
"latest-everything",
"v23.04.3",
edge_is_older
edge_is_older()
)
test(
"Latest-edge install with newer edge release",
release_filter_macro,
"latest-edge",
"v23.09.1-edge",
edge_is_newer
edge_is_newer()
)
test(
"Latest-edge install with older edge release",
release_filter_macro,
"latest-edge",
"v23.03.0-edge",
edge_is_older
edge_is_older()
)
test(
"Latest-stable install with newer edge release",
release_filter_macro,
"latest",
"v23.04.3",
edge_is_newer
edge_is_newer()
)
test(
"Latest-stable install with older edge release",
release_filter_macro,
"latest",
"v23.04.3",
edge_is_older
edge_is_older()
)
test(
"Fully versioned tag release",
release_filter_macro,
"v23.04.2",
"v23.04.2",
edge_is_newer
edge_is_newer()
)
test(
"Partially versioned tag release",
release_filter_macro,
"v23.04",
"v23.04.3",
edge_is_newer
edge_is_newer()
)
test.todo("install_nextflow")

View file

@ -2,8 +2,11 @@ import * as github from "@actions/github"
import { GitHub } from "@actions/github/lib/utils"
import anyTest, { TestFn } from "ava" // eslint-disable-line import/no-unresolved
import { nextflow_bin_url } from "../src/nextflow-release"
import { all_nf_release_data } from "../src/octokit-wrapper"
import { NextflowRelease } from "../src/nextflow-release"
import {
pull_latest_stable_release,
pull_releases
} from "../src/octokit-wrapper"
import { getToken } from "./utils"
const test = anyTest as TestFn<{