chore: generate
This commit is contained in:
parent
d28b5ad2f4
commit
4fc538378d
5 changed files with 27 additions and 13 deletions
|
|
@ -34,9 +34,7 @@ const program = Effect.gen(function* () {
|
||||||
Effect.runPromise(program.pipe(Effect.provide(HttpRecorder.cassetteLayer("users/get-one"))))
|
Effect.runPromise(program.pipe(Effect.provide(HttpRecorder.cassetteLayer("users/get-one"))))
|
||||||
|
|
||||||
// Record. Hits the upstream and writes the cassette.
|
// Record. Hits the upstream and writes the cassette.
|
||||||
Effect.runPromise(
|
Effect.runPromise(program.pipe(Effect.provide(HttpRecorder.cassetteLayer("users/get-one", { mode: "record" }))))
|
||||||
program.pipe(Effect.provide(HttpRecorder.cassetteLayer("users/get-one", { mode: "record" }))),
|
|
||||||
)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Set the mode from the environment in your test setup:
|
Set the mode from the environment in your test setup:
|
||||||
|
|
@ -190,12 +188,12 @@ const audit = Effect.gen(function* () {
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
type RecordReplayOptions = {
|
type RecordReplayOptions = {
|
||||||
mode?: "record" | "replay" | "passthrough" // default: "replay"
|
mode?: "record" | "replay" | "passthrough" // default: "replay"
|
||||||
directory?: string // default: <cwd>/test/fixtures/recordings
|
directory?: string // default: <cwd>/test/fixtures/recordings
|
||||||
metadata?: Record<string, unknown> // merged into cassette.metadata
|
metadata?: Record<string, unknown> // merged into cassette.metadata
|
||||||
redactor?: Redactor // default: Redactor.defaults()
|
redactor?: Redactor // default: Redactor.defaults()
|
||||||
dispatch?: "match" | "sequential" // default: "match"
|
dispatch?: "match" | "sequential" // default: "match"
|
||||||
match?: (incoming, recorded) => boolean // custom matcher
|
match?: (incoming, recorded) => boolean // custom matcher
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,4 +111,3 @@ export const layer = (options: { readonly directory?: string } = {}) =>
|
||||||
return Service.of({ path: pathFor, read, write, append, exists, list, scan: cassetteSecretFindings })
|
return Service.of({ path: pathFor, read, write, append, exists, list, scan: cassetteSecretFindings })
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,14 @@ const decodeResponseBody = (snapshot: ResponseSnapshot) =>
|
||||||
snapshot.bodyEncoding === "base64" ? Buffer.from(snapshot.body, "base64") : snapshot.body
|
snapshot.bodyEncoding === "base64" ? Buffer.from(snapshot.body, "base64") : snapshot.body
|
||||||
|
|
||||||
export const redactedErrorRequest = (request: HttpClientRequest.HttpClientRequest) =>
|
export const redactedErrorRequest = (request: HttpClientRequest.HttpClientRequest) =>
|
||||||
HttpClientRequest.makeWith(request.method, redactUrl(request.url), UrlParams.empty, Option.none(), Headers.empty, HttpBody.empty)
|
HttpClientRequest.makeWith(
|
||||||
|
request.method,
|
||||||
|
redactUrl(request.url),
|
||||||
|
UrlParams.empty,
|
||||||
|
Option.none(),
|
||||||
|
Headers.empty,
|
||||||
|
HttpBody.empty,
|
||||||
|
)
|
||||||
|
|
||||||
const transportError = (request: HttpClientRequest.HttpClientRequest, description: string) =>
|
const transportError = (request: HttpClientRequest.HttpClientRequest, description: string) =>
|
||||||
new HttpClientError.HttpClientError({
|
new HttpClientError.HttpClientError({
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,12 @@
|
||||||
export type { CassetteMetadata, HttpInteraction, Interaction, RequestSnapshot, ResponseSnapshot, WebSocketFrame, WebSocketInteraction } from "./schema"
|
export type {
|
||||||
|
CassetteMetadata,
|
||||||
|
HttpInteraction,
|
||||||
|
Interaction,
|
||||||
|
RequestSnapshot,
|
||||||
|
ResponseSnapshot,
|
||||||
|
WebSocketFrame,
|
||||||
|
WebSocketInteraction,
|
||||||
|
} from "./schema"
|
||||||
export { hasCassetteSync } from "./storage"
|
export { hasCassetteSync } from "./storage"
|
||||||
export { defaultMatcher, type RequestMatcher } from "./matching"
|
export { defaultMatcher, type RequestMatcher } from "./matching"
|
||||||
export { cassetteSecretFindings, redactHeaders, redactUrl, type SecretFinding } from "./redaction"
|
export { cassetteSecretFindings, redactHeaders, redactUrl, type SecretFinding } from "./redaction"
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,9 @@ export const makeReplayState = <T>(
|
||||||
if (used === 0) return
|
if (used === 0) return
|
||||||
const interactions = yield* load.pipe(Effect.orDie)
|
const interactions = yield* load.pipe(Effect.orDie)
|
||||||
if (used < interactions.length)
|
if (used < interactions.length)
|
||||||
yield* Effect.die(new Error(`Unused recorded interactions in ${name}: used ${used} of ${interactions.length}`))
|
yield* Effect.die(
|
||||||
|
new Error(`Unused recorded interactions in ${name}: used ${used} of ${interactions.length}`),
|
||||||
|
)
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue