-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into DX-1407-omit-trigger-and-cleanup-errors
- Loading branch information
Showing
33 changed files
with
1,090 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
|
||
export const FAILING_HEADER = "Fail-Header-Foo" | ||
export const FAILING_HEADER_VALUE = "fail-header-value-BAR" | ||
|
||
export const GET_HEADER = "Get-Header" | ||
export const GET_HEADER_VALUE = "get-header-value-FOO" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
This directory has a endpoints testing the lazy fetch functionality: | ||
- `call-result`: endpoint called with context.call returns a large payload | ||
- `error`: a large error is thrown. failureFunction is called with the initial body. | ||
- `initial`: workflow is started with a large object | ||
- `step-result`: a step returns a large result | ||
- `step-result-parallel`: a parallel step returns a large result | ||
|
||
In `utils.ts`, you can find the large object used. |
13 changes: 13 additions & 0 deletions
13
examples/ci/app/test-routes/large-payload/call-result/third-party/route.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { GET_HEADER, GET_HEADER_VALUE, largeObject } from "../../utils" | ||
|
||
export const GET = async () => { | ||
return new Response( | ||
largeObject, | ||
{ | ||
status: 201, | ||
headers: { | ||
[ GET_HEADER ]: GET_HEADER_VALUE | ||
} | ||
} | ||
) | ||
} |
54 changes: 54 additions & 0 deletions
54
examples/ci/app/test-routes/large-payload/call-result/workflow/route.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { serve } from "@upstash/workflow/nextjs"; | ||
import { BASE_URL, TEST_ROUTE_PREFIX } from "app/ci/constants"; | ||
import { testServe, expect } from "app/ci/utils"; | ||
import { saveResult } from "app/ci/upstash/redis" | ||
import { GET_HEADER, GET_HEADER_VALUE, largeObject, largeObjectLength } from "../../utils"; | ||
|
||
const header = `test-header-foo` | ||
const headerValue = `header-bar` | ||
const payload = "“unicode-quotes”" | ||
|
||
const thirdPartyEndpoint = `${TEST_ROUTE_PREFIX}/large-payload/call-result/third-party` | ||
|
||
export const { POST, GET } = testServe( | ||
serve<string>( | ||
async (context) => { | ||
const input = context.requestPayload; | ||
|
||
expect(context.headers.get(header)!, headerValue) | ||
|
||
const { body: result1, status, header: headers } = await context.call<string>("get large bod", { | ||
url: thirdPartyEndpoint, | ||
method: "GET" | ||
}) | ||
|
||
expect(input, payload); | ||
|
||
expect(status, 201) | ||
expect(result1, largeObject) | ||
expect(result1.length, largeObjectLength) | ||
expect(headers[GET_HEADER][0], GET_HEADER_VALUE) | ||
|
||
const result2 = await context.run("step2", () => { | ||
return result1.length | ||
}); | ||
|
||
expect(result2, largeObjectLength); | ||
|
||
await saveResult( | ||
context, | ||
result2.toString() | ||
) | ||
}, { | ||
baseUrl: BASE_URL, | ||
retries: 0 | ||
} | ||
), { | ||
expectedCallCount: 5, | ||
expectedResult: largeObjectLength.toString(), | ||
payload, | ||
headers: { | ||
[ header ]: headerValue | ||
} | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { serve } from "@upstash/workflow/nextjs"; | ||
import { BASE_URL } from "app/ci/constants"; | ||
import { testServe, expect } from "app/ci/utils"; | ||
import { saveResult } from "app/ci/upstash/redis" | ||
import { largeObject } from "../utils"; | ||
import { WorkflowContext } from "@upstash/workflow"; | ||
|
||
const header = `test-header-foo` | ||
const headerValue = `header-bar` | ||
const payload = "“unicode-quotes”" | ||
|
||
export const { POST, GET } = testServe( | ||
serve<string>( | ||
async (context) => { | ||
const input = context.requestPayload; | ||
|
||
expect(input, payload); | ||
expect(context.headers.get(header)!, headerValue) | ||
|
||
const result1 = await context.run("step1", () => { | ||
return input.length; | ||
}); | ||
|
||
expect(result1, payload.length); | ||
|
||
await context.run("step2", () => { | ||
throw new Error(largeObject) | ||
}); | ||
}, { | ||
baseUrl: BASE_URL, | ||
retries: 0, | ||
async failureFunction({ context, failStatus, failResponse }) { | ||
expect( failResponse, largeObject ) | ||
expect( failStatus, 500 ) | ||
expect( context.requestPayload as string, payload ) | ||
|
||
await saveResult( | ||
context as WorkflowContext, | ||
`super secret` | ||
) | ||
}, | ||
} | ||
), { | ||
expectedCallCount: 4, | ||
expectedResult: `super secret`, | ||
payload, | ||
headers: { | ||
[ header ]: headerValue | ||
} | ||
} | ||
) |
56 changes: 56 additions & 0 deletions
56
examples/ci/app/test-routes/large-payload/initial/route.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { serve } from "@upstash/workflow/nextjs"; | ||
import { BASE_URL } from "app/ci/constants"; | ||
import { testServe, expect } from "app/ci/utils"; | ||
import { saveResult } from "app/ci/upstash/redis" | ||
import { largeObject } from "../utils"; | ||
import { WorkflowContext } from "@upstash/workflow"; | ||
|
||
const header = `test-header-foo` | ||
const headerValue = `header-bar` | ||
const throws = "throwing-foo" | ||
|
||
export const { POST, GET } = testServe( | ||
serve<string>( | ||
async (context) => { | ||
const input = context.requestPayload; | ||
|
||
expect(input, largeObject); | ||
expect(context.headers.get(header)!, headerValue) | ||
|
||
const result1 = await context.run("step1", () => { | ||
return input.length; | ||
}); | ||
|
||
expect(result1, largeObject.length); | ||
|
||
const result2 = await context.run("step2", () => { | ||
return input | ||
}); | ||
|
||
expect(result2, largeObject); | ||
|
||
await context.run("throws", () => { | ||
throw new Error(throws) | ||
}) | ||
}, { | ||
baseUrl: BASE_URL, | ||
retries: 0, | ||
async failureFunction({ context, failResponse }) { | ||
expect(context.requestPayload as string, largeObject) | ||
expect(failResponse, throws) | ||
|
||
await saveResult( | ||
context as WorkflowContext, | ||
throws | ||
) | ||
}, | ||
} | ||
), { | ||
expectedCallCount: 5, | ||
expectedResult: throws, | ||
payload: largeObject, | ||
headers: { | ||
[ header ]: headerValue | ||
} | ||
} | ||
) |
59 changes: 59 additions & 0 deletions
59
examples/ci/app/test-routes/large-payload/step-result-parallel/route.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { serve } from "@upstash/workflow/nextjs"; | ||
import { BASE_URL } from "app/ci/constants"; | ||
import { testServe, expect } from "app/ci/utils"; | ||
import { saveResult } from "app/ci/upstash/redis" | ||
import { largeObject, largeObjectLength } from "../utils"; | ||
|
||
const header = `test-header-foo` | ||
const headerValue = `header-bar` | ||
const payload = "foo" | ||
|
||
export const { POST, GET } = testServe( | ||
serve<string>( | ||
async (context) => { | ||
const input = context.requestPayload; | ||
|
||
expect(input, payload); | ||
expect(context.headers.get(header)!, headerValue) | ||
|
||
const [result1, largeResult1] = await Promise.all([ | ||
context.run("step 1", () => undefined), | ||
context.run("step 2 - large", () => { | ||
return largeObject; | ||
}) | ||
]) | ||
|
||
expect(typeof result1, "undefined"); | ||
expect(typeof largeResult1, "string"); | ||
expect(largeResult1.length, largeObjectLength); | ||
expect(largeResult1, largeObject); | ||
|
||
const [largeResult2, result2] = await Promise.all([ | ||
context.run("step 3 - large", () => { | ||
return largeObject; | ||
}), | ||
context.run("step 4", () => undefined), | ||
]) | ||
|
||
expect(typeof result2, "undefined"); | ||
expect(typeof largeResult2, "string"); | ||
expect(largeResult2.length, largeObjectLength); | ||
expect(largeResult2, largeObject); | ||
|
||
await saveResult( | ||
context, | ||
`${largeResult1.length} - ${largeResult2.length}` | ||
) | ||
}, { | ||
baseUrl: BASE_URL, | ||
retries: 0, | ||
} | ||
), { | ||
expectedCallCount: 10, | ||
expectedResult: `${largeObjectLength} - ${largeObjectLength}`, | ||
payload, | ||
headers: { | ||
[ header ]: headerValue | ||
} | ||
} | ||
) |
Oops, something went wrong.