Fix tests.
This commit is contained in:
parent
5fc5524693
commit
3a74df0a4a
|
@ -43,9 +43,7 @@ describe("test the openai action", () => {
|
||||||
|
|
||||||
it("should present the correct error message when the OPENAI_API_KEY variable isn't set", async () => {
|
it("should present the correct error message when the OPENAI_API_KEY variable isn't set", async () => {
|
||||||
await config.withCoreEnv({ OPENAI_API_KEY: "" }, async () => {
|
await config.withCoreEnv({ OPENAI_API_KEY: "" }, async () => {
|
||||||
let res = await runStep("OPENAI", {
|
let res = await runStep("OPENAI", { prompt: OPENAI_PROMPT })
|
||||||
prompt: OPENAI_PROMPT,
|
|
||||||
})
|
|
||||||
expect(res.response).toEqual(
|
expect(res.response).toEqual(
|
||||||
"OpenAI API Key not configured - please add the OPENAI_API_KEY environment variable."
|
"OpenAI API Key not configured - please add the OPENAI_API_KEY environment variable."
|
||||||
)
|
)
|
||||||
|
@ -54,17 +52,13 @@ describe("test the openai action", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should be able to receive a response from ChatGPT given a prompt", async () => {
|
it("should be able to receive a response from ChatGPT given a prompt", async () => {
|
||||||
const res = await runStep("OPENAI", {
|
const res = await runStep("OPENAI", { prompt: OPENAI_PROMPT })
|
||||||
prompt: OPENAI_PROMPT,
|
|
||||||
})
|
|
||||||
expect(res.response).toEqual("This is a test")
|
expect(res.response).toEqual("This is a test")
|
||||||
expect(res.success).toBeTruthy()
|
expect(res.success).toBeTruthy()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should present the correct error message when a prompt is not provided", async () => {
|
it("should present the correct error message when a prompt is not provided", async () => {
|
||||||
const res = await runStep("OPENAI", {
|
const res = await runStep("OPENAI", { prompt: null })
|
||||||
prompt: null,
|
|
||||||
})
|
|
||||||
expect(res.response).toEqual(
|
expect(res.response).toEqual(
|
||||||
"Budibase OpenAI Automation Failed: No prompt supplied"
|
"Budibase OpenAI Automation Failed: No prompt supplied"
|
||||||
)
|
)
|
||||||
|
|
|
@ -290,7 +290,7 @@ export default class TestConfiguration {
|
||||||
* that can be called to reset the environment variables to their original values.
|
* that can be called to reset the environment variables to their original values.
|
||||||
*/
|
*/
|
||||||
setCoreEnv(newEnvVars: Partial<typeof coreEnv>): () => void {
|
setCoreEnv(newEnvVars: Partial<typeof coreEnv>): () => void {
|
||||||
const oldEnv = cloneDeep(env)
|
const oldEnv = cloneDeep(coreEnv)
|
||||||
|
|
||||||
let key: keyof typeof newEnvVars
|
let key: keyof typeof newEnvVars
|
||||||
for (key in newEnvVars) {
|
for (key in newEnvVars) {
|
||||||
|
|
Loading…
Reference in New Issue