|
| 1 | +import * as NodePath from "@effect/platform-node/NodePath"; |
| 2 | +import * as NodeServices from "@effect/platform-node/NodeServices"; |
| 3 | +import { assert, describe, it } from "@effect/vitest"; |
| 4 | +import { buildRemoteT3RunnerScript } from "@t3tools/ssh/tunnel"; |
| 5 | +import * as Effect from "effect/Effect"; |
| 6 | +import * as Layer from "effect/Layer"; |
| 7 | + |
| 8 | +import * as DesktopConfig from "../app/DesktopConfig.ts"; |
| 9 | +import * as DesktopEnvironment from "../app/DesktopEnvironment.ts"; |
| 10 | +import * as DesktopSshEnvironment from "./DesktopSshEnvironment.ts"; |
| 11 | + |
| 12 | +const runnerScript = (env: Record<string, string | undefined>) => |
| 13 | + DesktopEnvironment.DesktopEnvironment.pipe( |
| 14 | + Effect.map((environment) => |
| 15 | + buildRemoteT3RunnerScript(DesktopSshEnvironment.resolveCliRunner(environment)), |
| 16 | + ), |
| 17 | + Effect.provide( |
| 18 | + DesktopEnvironment.layer({ |
| 19 | + dirname: "/repo/apps/desktop/dist-electron", |
| 20 | + homeDirectory: "/home/alice", |
| 21 | + platform: "linux", |
| 22 | + processArch: "x64", |
| 23 | + appVersion: "0.1.6", |
| 24 | + appPath: "/opt/t3code/resources/app.asar", |
| 25 | + isPackaged: true, |
| 26 | + resourcesPath: "/opt/t3code/resources", |
| 27 | + runningUnderArm64Translation: false, |
| 28 | + }).pipe( |
| 29 | + Layer.provide( |
| 30 | + Layer.mergeAll(NodeServices.layer, NodePath.layerPosix, DesktopConfig.layerTest(env)), |
| 31 | + ), |
| 32 | + ), |
| 33 | + ), |
| 34 | + ); |
| 35 | + |
| 36 | +describe("resolveCliRunner", () => { |
| 37 | + it.effect("downloads the remote runtime from T3CODE_RELEASE_BASE_URL", () => |
| 38 | + Effect.gen(function* () { |
| 39 | + const cases = [ |
| 40 | + [{ T3CODE_RELEASE_BASE_URL: "https://mirror.example/t3/" }, "https://mirror.example/t3"], |
| 41 | + [ |
| 42 | + { T3CODE_RELEASE_BASE_URL: " " }, |
| 43 | + "https://github.com/pingdotgg/t3code/releases/download", |
| 44 | + ], |
| 45 | + [{}, "https://github.com/pingdotgg/t3code/releases/download"], |
| 46 | + ] as const; |
| 47 | + for (const [env, expected] of cases) { |
| 48 | + const script = yield* runnerScript(env); |
| 49 | + assert.include(script, `T3_RELEASE_BASE_URL='${expected}'`); |
| 50 | + assert.include(script, `T3_ARCHIVE_VERSION='0.1.6'`); |
| 51 | + } |
| 52 | + }), |
| 53 | + ); |
| 54 | +}); |
0 commit comments