Skip to content

Commit 40262b1

Browse files
committed
Add getRepositoryProperties to api-client, for easier mocking
1 parent b4f966a commit 40262b1

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

lib/init-action.js

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/api-client.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as retry from "@octokit/plugin-retry";
44
import consoleLogLevel from "console-log-level";
55

66
import { getActionVersion, getRequiredInput } from "./actions-util";
7-
import { getRepositoryNwo } from "./repository";
7+
import { getRepositoryNwo, RepositoryNwo } from "./repository";
88
import {
99
ConfigurationError,
1010
getRequiredEnvParam,
@@ -240,6 +240,14 @@ export async function deleteActionsCache(id: number) {
240240
});
241241
}
242242

243+
/** Retrieve all custom repository properties. */
244+
export async function getRepositoryProperties(repositoryNwo: RepositoryNwo) {
245+
return getApiClient().request("GET /repos/:owner/:repo/properties/values", {
246+
owner: repositoryNwo.owner,
247+
repo: repositoryNwo.repo,
248+
});
249+
}
250+
243251
export function wrapApiConfigurationError(e: unknown) {
244252
if (isHTTPError(e)) {
245253
if (

src/feature-flags/properties.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getApiClient } from "../api-client";
1+
import { getRepositoryProperties } from "../api-client";
22
import { Logger } from "../logging";
33
import { RepositoryNwo } from "../repository";
44

@@ -41,13 +41,7 @@ export async function loadPropertiesFromApi(
4141
repositoryNwo: RepositoryNwo,
4242
): Promise<RepositoryProperties> {
4343
try {
44-
const response = await getApiClient().request(
45-
"GET /repos/:owner/:repo/properties/values",
46-
{
47-
owner: repositoryNwo.owner,
48-
repo: repositoryNwo.repo,
49-
},
50-
);
44+
const response = await getRepositoryProperties(repositoryNwo);
5145
const remoteProperties = response.data as GitHubPropertiesResponse;
5246

5347
if (!Array.isArray(remoteProperties)) {

0 commit comments

Comments
 (0)