Skip to content

Commit

Permalink
feat!: Remove manual API calling tests
Browse files Browse the repository at this point in the history
These tests are no longer used since the switch to OctokitWrapper, and
conflict with packages required for the implementation of throttling, so
remove them.
  • Loading branch information
MillironX committed Jan 22, 2024
1 parent 8982670 commit 2098c3c
Showing 1 changed file with 0 additions and 30 deletions.
30 changes: 0 additions & 30 deletions test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import fetch from "node-fetch"

export function getToken(first: boolean): string {
const token = process.env["GITHUB_TOKEN"] || ""
if (!token && first) {
Expand All @@ -12,31 +10,3 @@ export function getToken(first: boolean): string {

return token
}

/**
* Retrieves the release from a GitHub repository. This function allows to fetch
* either the latest release or the latest pre-release ("edge" release).
*
* @param {string} repo - The GitHub repository to fetch the release from,
* in the format 'owner/repo'.
* @param {boolean} [prerelease] - If true, fetches the latest pre-release.
* If false or undefined, fetches the latest release regardless of whether
* it's a pre-release or not.
*
* @returns {Promise<string>} A Promise that resolves to a string representing the tag name
* of the found release. If no release is found, the Promise resolves to 'Release not found'.
*/
export async function getReleaseTag(
repo: string,
prerelease?: boolean
): Promise<string> {
const response = await fetch(`https://api.github.com/repos/${repo}/releases`)
const releases = await response.json()

const release = releases.find(
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
(rel: any) => prerelease === undefined || rel.prerelease === prerelease
)

return release ? release.tag_name : "No release found"
}

0 comments on commit 2098c3c

Please sign in to comment.