feat: introduce APIs to update envs from tests and recursive resolution
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import { pipe } from "fp-ts/lib/function"
|
||||
import { chain, right } from "fp-ts/lib/TaskEither"
|
||||
import { pipe } from "fp-ts/function"
|
||||
import * as TE from "fp-ts/TaskEither"
|
||||
import { execPreRequestScript } from "./preRequest"
|
||||
import {
|
||||
execTestScript,
|
||||
TestResponse,
|
||||
TestDescriptor as _TestDescriptor,
|
||||
TestResult,
|
||||
} from "./test-runner"
|
||||
|
||||
export type TestDescriptor = _TestDescriptor
|
||||
@@ -13,10 +14,19 @@ export type TestDescriptor = _TestDescriptor
|
||||
* @param testScript The string of the script to run
|
||||
* @returns A TaskEither with an error message or a TestDescriptor with the final status
|
||||
*/
|
||||
export const runTestScript = (testScript: string, response: TestResponse) =>
|
||||
export const runTestScript = (
|
||||
testScript: string,
|
||||
envs: TestResult["envs"],
|
||||
response: TestResponse
|
||||
) =>
|
||||
pipe(
|
||||
execTestScript(testScript, response),
|
||||
chain((results) => right(results[0])) // execTestScript returns an array of descriptors with a single element (extract that)
|
||||
execTestScript(testScript, envs, response),
|
||||
TE.chain((results) =>
|
||||
TE.right(<TestResult & { tests: TestDescriptor }>{
|
||||
envs: results.envs,
|
||||
tests: results.tests[0],
|
||||
})
|
||||
) // execTestScript returns an array of descriptors with a single element (extract that)
|
||||
)
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user