setup-nextflow/test/releasedata.ts

42 lines
1.4 KiB
TypeScript
Raw Normal View History

import * as github from "@actions/github"
import { GitHub } from "@actions/github/lib/utils"
import anyTest, { TestFn } from "ava" // eslint-disable-line import/no-unresolved
2024-01-09 12:28:07 +00:00
import { nextflow_bin_url } from "../src/nextflow-release"
import { all_nf_release_data } from "../src/octokit-wrapper"
2023-12-23 17:48:58 +00:00
import { getToken } from "./utils"
2022-11-14 03:22:12 +00:00
2022-11-14 02:27:54 +00:00
const test = anyTest as TestFn<{
token: string
octokit: InstanceType<typeof GitHub>
}>
test.before(t => {
const first = true
const current_token = getToken(first)
2022-11-14 02:29:05 +00:00
t.context = {
token: current_token,
octokit: github.getOctokit(current_token)
}
})
2023-12-23 17:48:58 +00:00
const exists_macro = test.macro(async (t, object_name: string) => {
const all_releases = await all_nf_release_data(t.context.octokit)
const first_release = all_releases[0]
t.assert(first_release.hasOwnProperty(object_name))
})
test("OctoKit returns tag", exists_macro, "tag_name")
test("Octokit returns prerelease", exists_macro, "prerelease")
test("Octokit returns assets", exists_macro, "assets")
const binary_url_macro = test.macro(async (t, get_all: boolean) => {
const all_releases = await all_nf_release_data(t.context.octokit)
const first_release = all_releases[0]
const url = nextflow_bin_url(first_release, get_all)
t.notThrows(() => new URL(url))
})
2023-12-23 17:48:58 +00:00
test("Nextflow binary URL valid", binary_url_macro, false)
test("Nextflow 'all' binary URL valid", binary_url_macro, true)