-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unify test and prod app config factory functions, add a getter for ap…
…p config based on env variable and add fresh http server test
- Loading branch information
1 parent
2903402
commit c945d14
Showing
5 changed files
with
47 additions
and
8 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 |
---|---|---|
|
@@ -9,7 +9,7 @@ import { createFailure, createOk } from "../src/result.ts"; | |
import { assertEquals } from "https://deno.land/[email protected]/assert/mod.ts"; | ||
import { createPromise } from "./common.ts"; | ||
|
||
const SUCCESSFUL_CHAT_GPT_CAPTIONS_SUMMARY = | ||
export const SUCCESSFUL_CHAT_GPT_CAPTIONS_SUMMARY = | ||
`The video is a music video for the song "Never Gonna Give You Up" by Rick | ||
Astley. The captions display the lyrics of the song, which talk about love | ||
and commitment, assuring that the singer will never give up on the person | ||
|
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,5 +1,5 @@ | ||
// Entrypoint to run "just tell me" from the command line interface. | ||
import { ProdAppConfig } from "./app/src/app-config.ts"; | ||
import { getAppConfig } from "./app/src/app-config.ts"; | ||
import { Result } from "./app/src/result.ts"; | ||
import { parseArgs } from "https://deno.land/[email protected]/cli/parse_args.ts"; | ||
|
||
|
@@ -16,7 +16,7 @@ async function run() { | |
string: ["model"], | ||
}); | ||
|
||
const appConfigResult = ProdAppConfig.create(flags.model); | ||
const appConfigResult = await getAppConfig(flags.model); | ||
if (appConfigResult.result === Result.Failure) { | ||
console.log(appConfigResult.failure, "\n", appConfigResult.message); | ||
} else { | ||
|
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,29 @@ | ||
import { createHandler, ServeHandlerInfo } from "$fresh/server.ts"; | ||
import manifest from "../fresh.gen.ts"; | ||
import config from "../fresh.config.ts"; | ||
import { assert } from "$std/assert/assert.ts"; | ||
|
||
const CONN_INFO: ServeHandlerInfo = { | ||
remoteAddr: { hostname: "127.0.0.1", port: 53496, transport: "tcp" }, | ||
}; | ||
|
||
Deno.test("HTTP tests", async (t) => { | ||
Deno.env.set("TEST", "true"); | ||
|
||
const handler = await createHandler(manifest, config); | ||
|
||
await t.step("GET /summary/youtube?id=test", async () => { | ||
const response = await handler( | ||
new Request("http://127.0.0.1/summary/youtube?id=test"), | ||
CONN_INFO, | ||
); | ||
const text = await response.text(); | ||
assert( | ||
text.includes( | ||
"The video is a music video for the song "Never Gonna Give You Up"", | ||
), | ||
); | ||
}); | ||
|
||
Deno.env.delete("TEST"); | ||
}); |