Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/server/src/cli/connect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ it.effect("does not install the relay client when the user declines the managed
let installCalls = 0;
const result = yield* acquireRelayClientForLink(
{
prepare: Effect.die("link inspection must not prepare the relay client"),
resolve: Effect.succeed({
status: "missing",
version: RelayClient.CLOUDFLARED_VERSION,
Expand Down Expand Up @@ -87,6 +88,7 @@ it.effect("installs the relay client after the user accepts the managed download
const progress: Array<string> = [];
const result = yield* acquireRelayClientForLink(
{
prepare: Effect.die("link inspection must not prepare the relay client"),
resolve: Effect.succeed({
status: "missing",
version: RelayClient.CLOUDFLARED_VERSION,
Expand Down Expand Up @@ -125,6 +127,7 @@ it.effect("reuses an available relay client executable without prompting", () =>
let promptCalls = 0;
const result = yield* acquireRelayClientForLink(
{
prepare: Effect.die("link inspection must not prepare the relay client"),
resolve: Effect.succeed(managedExecutable),
install: Effect.die("unexpected install"),
installWithProgress: () => Effect.die("unexpected install"),
Expand Down
22 changes: 19 additions & 3 deletions apps/server/src/cloud/ManagedEndpointRuntime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import * as ManagedEndpointRuntime from "./ManagedEndpointRuntime.ts";
const layerRelayClientAvailable = Layer.succeed(
RelayClient.RelayClient,
RelayClient.RelayClient.of({
resolve: Effect.succeed({
resolve: Effect.die("launch must prepare the relay client"),
prepare: Effect.succeed({
status: "available",
executablePath: "cloudflared",
source: "path",
Expand Down Expand Up @@ -341,7 +342,20 @@ describe("CloudManagedEndpointRuntime", () => {
return handle;
}),
);
const runtime = yield* buildCloudManagedEndpointRuntime(spawner);
const relayClient = yield* RelayClient.RelayClient.pipe(
Effect.provide(layerRelayClientAvailable),
);
let preparations = 0;
const runtime = yield* buildCloudManagedEndpointRuntime(
spawner,
Layer.succeed(RelayClient.RelayClient, {
...relayClient,
prepare: Effect.sync(() => {
expect(killed).toHaveLength(spawned.length);
preparations += 1;
}).pipe(Effect.andThen(relayClient.prepare)),
}),
);

yield* runtime.applyConfig({
providerKind: "cloudflare_tunnel",
Expand Down Expand Up @@ -377,6 +391,7 @@ describe("CloudManagedEndpointRuntime", () => {
expect(spawned.map((command) => command.options.detached)).toEqual([false, false]);
expect(spawned.map((command) => command.options.shell)).toEqual([false, false]);
expect(killed).toEqual([100, 101]);
expect(preparations).toBe(2);
expect(stopped).toEqual({ status: "disabled" });
}),
);
Expand Down Expand Up @@ -732,7 +747,8 @@ describe("CloudManagedEndpointRuntime", () => {
Layer.succeed(
RelayClient.RelayClient,
RelayClient.RelayClient.of({
resolve: Effect.succeed({
resolve: Effect.die("launch must prepare the relay client"),
prepare: Effect.succeed({
status: "missing",
version: RelayClient.CLOUDFLARED_VERSION,
}),
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/cloud/ManagedEndpointRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export const make = Effect.gen(function* () {

yield* stopActive;

const executable = yield* relayClient.resolve;
const executable = yield* relayClient.prepare;
if (executable.status !== "available") {
return {
status: "failed",
Expand Down
Loading
Loading