Skip to content

Commit 9afcef1

Browse files
committed
refactor: rename getRunId to getRunIdAndUrl
1 parent 4631cd5 commit 9afcef1

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

src/main.spec.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ describe("main", () => {
5959
>;
6060

6161
// Return Dispatch
62-
let returnDispatchGetRunIdMock: MockInstance<typeof returnDispatch.getRunId>;
62+
let returnDispatchGetRunIdAndUrlMock: MockInstance<
63+
typeof returnDispatch.getRunIdAndUrl
64+
>;
6365
let returnDispatchGetWorkflowIdMock: MockInstance<
6466
typeof returnDispatch.getWorkflowId
6567
>;
@@ -92,7 +94,7 @@ describe("main", () => {
9294
"logInfoForBranchNameResult",
9395
);
9496

95-
returnDispatchGetRunIdMock = vi.spyOn(returnDispatch, "getRunId");
97+
returnDispatchGetRunIdAndUrlMock = vi.spyOn(returnDispatch, "getRunIdAndUrl");
9698
returnDispatchGetWorkflowIdMock = vi
9799
.spyOn(returnDispatch, "getWorkflowId")
98100
.mockResolvedValue(0);
@@ -119,7 +121,9 @@ describe("main", () => {
119121

120122
utilsGetBranchNameMock.mockReturnValue(testBranch);
121123
returnDispatchGetWorkflowIdMock.mockResolvedValue(0);
122-
returnDispatchGetRunIdMock.mockResolvedValue(returnDispatchSuccessResult);
124+
returnDispatchGetRunIdAndUrlMock.mockResolvedValue(
125+
returnDispatchSuccessResult,
126+
);
123127

124128
await main();
125129

@@ -149,8 +153,8 @@ describe("main", () => {
149153
);
150154

151155
// Get run ID
152-
expect(returnDispatchGetRunIdMock).toHaveBeenCalledOnce();
153-
expect(returnDispatchGetRunIdMock).toHaveBeenCalledWith({
156+
expect(returnDispatchGetRunIdAndUrlMock).toHaveBeenCalledOnce();
157+
expect(returnDispatchGetRunIdAndUrlMock).toHaveBeenCalledWith({
154158
startTime: Date.now(),
155159
branch: testBranch,
156160
distinctId: testCfg.distinctId,
@@ -196,7 +200,7 @@ describe("main", () => {
196200
expect(apiDispatchWorkflowMock).not.toHaveBeenCalled();
197201
expect(utilsGetBranchNameMock).not.toHaveBeenCalled();
198202
expect(utilsLogInfoForBranchNameResult).not.toHaveBeenCalled();
199-
expect(returnDispatchGetRunIdMock).not.toHaveBeenCalled();
203+
expect(returnDispatchGetRunIdAndUrlMock).not.toHaveBeenCalled();
200204
expect(returnDispatchHandleFailMock).not.toHaveBeenCalled();
201205
expect(returnDispatchHandleSuccessMock).not.toHaveBeenCalled();
202206

@@ -232,7 +236,7 @@ describe("main", () => {
232236
expect(apiDispatchWorkflowMock).not.toHaveBeenCalled();
233237
expect(utilsGetBranchNameMock).not.toHaveBeenCalled();
234238
expect(utilsLogInfoForBranchNameResult).not.toHaveBeenCalled();
235-
expect(returnDispatchGetRunIdMock).not.toHaveBeenCalled();
239+
expect(returnDispatchGetRunIdAndUrlMock).not.toHaveBeenCalled();
236240
expect(returnDispatchHandleFailMock).not.toHaveBeenCalled();
237241
expect(returnDispatchHandleSuccessMock).not.toHaveBeenCalled();
238242

src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
getWorkflowId,
77
handleActionFail,
88
handleActionSuccess,
9-
getRunId,
9+
getRunIdAndUrl,
1010
} from "./return-dispatch.ts";
1111
import { getBranchName, logInfoForBranchNameResult } from "./utils.ts";
1212

@@ -27,7 +27,7 @@ export async function main(): Promise<void> {
2727
const branch = getBranchName(config.ref);
2828
logInfoForBranchNameResult(branch, config.ref);
2929

30-
const result = await getRunId({
30+
const result = await getRunIdAndUrl({
3131
startTime,
3232
branch,
3333
distinctId: config.distinctId,

src/return-dispatch.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,22 +116,22 @@ export function handleActionFail(): void {
116116
core.setFailed("Timeout exceeded while attempting to get Run ID");
117117
}
118118

119-
interface GetRunIdOpts {
119+
export interface GetRunIdAndUrlOpts {
120120
startTime: number;
121121
branch: BranchNameResult;
122122
distinctId: string;
123123
workflow: string | number;
124124
workflowId: number;
125125
workflowTimeoutMs: number;
126126
}
127-
export async function getRunId({
127+
export async function getRunIdAndUrl({
128128
startTime,
129129
branch,
130130
distinctId,
131131
workflow,
132132
workflowId,
133133
workflowTimeoutMs,
134-
}: GetRunIdOpts): Promise<Result<{ id: number; url: string }>> {
134+
}: GetRunIdAndUrlOpts): Promise<Result<{ id: number; url: string }>> {
135135
const distinctIdRegex = new RegExp(distinctId);
136136

137137
core.info("Attempt to identify run ID from steps...");

0 commit comments

Comments
 (0)