setup-nextflow/test/releasedata.ts

40 lines
1.3 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
2023-09-26 22:25:10 +00:00
import { getToken } from "./utils"
import { latest_stable_release_data } from "../src/OctokitWrapper"
import { nextflow_bin_url } from "../src/NextflowRelease"
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-09-26 22:25:10 +00:00
const exists_macro = test.macro(async (t, object_name: string) => {
const first_release = await latest_stable_release_data(t.context.octokit)
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 first_release = await latest_stable_release_data(t.context.octokit)
const url = nextflow_bin_url(first_release, get_all)
t.notThrows(() => new URL(url))
})
2023-09-26 22:25:10 +00:00
test("Nextflow binary URL valid", binary_url_macro, false)
test("Nextflow 'all' binary URL valid", binary_url_macro, true)