From 4443761addba3b8271cbd1ed776a40b998977441 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Sat, 23 Dec 2023 10:48:58 -0700 Subject: [PATCH] test: Update API consistency tests --- test/releasedata.ts | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/test/releasedata.ts b/test/releasedata.ts index 2b086f2..3796054 100644 --- a/test/releasedata.ts +++ b/test/releasedata.ts @@ -2,8 +2,9 @@ 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 { release_data } from "../src/functions" -import { getReleaseTag, getToken } from "./utils" +import { nextflow_bin_url } from "../src/NextflowRelease" +import { all_nf_release_data } from "../src/OctokitWrapper" +import { getToken } from "./utils" const test = anyTest as TestFn<{ token: string @@ -19,22 +20,22 @@ test.before(t => { } }) -const macro = test.macro(async (t, version: string) => { - let expected - if (version === "latest-stable") { - expected = await getReleaseTag("nextflow-io/nextflow", false) - } else if (version === "latest-edge") { - expected = await getReleaseTag("nextflow-io/nextflow", true) - } else if (version === "latest-everything") { - expected = await getReleaseTag("nextflow-io/nextflow", undefined) - } else { - expected = version - } - const result = await release_data(version, t.context["octokit"]) - t.is(result["tag_name"], expected) +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("hard version", macro, "v22.10.2") -test("latest-stable", macro, "latest-stable") -test("latest-edge", macro, "latest-edge") -test("latest-everything", macro, "latest-everything") +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)) +}) + +test("Nextflow binary URL valid", binary_url_macro, false) +test("Nextflow 'all' binary URL valid", binary_url_macro, true)