Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions examples/ci/app/ci/upstash/qstash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,6 @@ export const startWorkflow = async (
return result
}

/**
* throws error if workflow hasn't started
*
* @param messageId
* @returns
*/
export const checkWorkflowStart = async (workflowRunId: string) => {

const results = await workflowClient.logs({ workflowRunId })
const firstRun = results.runs[0]
const startMessageDelivered = firstRun && firstRun.steps.length > 1
if (!startMessageDelivered) {
await workflowClient.cancel({ ids: [ workflowRunId ] })
throw new Error(firstRun ? `Couldn't verify that workflow has begun. Number of steps: ${firstRun.steps.length}` : "No runs found")
}
}

export const getWorkflowLogs = async (workflowRunId: string) => {
const results = await workflowClient.logs({ workflowRunId })
return results
Expand Down
37 changes: 0 additions & 37 deletions examples/ci/app/ci/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,6 @@ export const initiateTest = async (params: Pick<TestConfig, "route">) => {
// sleep for 4 secs and check that message is delivered
await new Promise(r => setTimeout(r, CHECK_WF_AFTER_INIT_DURATION));

try {
await eventually(async () => {
await qstash.checkWorkflowStart(workflowRunId);
})
} catch (error) {
console.error(error);
if (shouldWorkflowStart) {
throw error;
};
}

try {
await redis.checkRedisForResults(route, randomTestId, expectedCallCount, expectedResult)
} catch (error) {
Expand Down Expand Up @@ -121,29 +110,3 @@ export const expect = <TObject extends ExpectType = ExpectType>(
throw new Error(`Unexpected value.\n\tReceived "${received}"\n\tExpected "${expected}"`)
}
}

export const eventually = async function (
fn: () => Promise<void> | void,
options: {
timeout?: number;
interval?: number;
} = {}
): Promise<void> {
const { timeout = 5000, interval = 100 } = options;

const startTime = Date.now();

while (true) {
try {
await fn();
// Success case - all assertions passed
return;
} catch (error) {
const lastError = error as Error;
if (Date.now() - startTime >= timeout) {
throw new Error(`Assertions not satisfied within timeout: ${lastError.message}`);
}
await new Promise((resolve) => setTimeout(resolve, interval));
}
}
};
Loading