Something went wrong. Try again.
Monorepo for Tangled tangled.org
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647import { describe, expect, it } from "vitest";import { resolveConfig } from "#lib/server/config.ts";
const fosterKnotUrl = (foster?: string) => resolveConfig({ FOSTER_KNOT_URL: foster }).fosterKnotUrl;
describe("resolveConfig fosterKnotUrl", () => { it("parses a bare-origin url into the knot origin, ignoring a trailing slash", () => { expect(fosterKnotUrl("https://foster.test")).toBe("foster.test"); expect(fosterKnotUrl("https://foster.test/")).toBe("foster.test"); expect(fosterKnotUrl("http://127.0.0.1:5555")).toBe("127.0.0.1:5555"); });
it("is empty when unset or blank", () => { expect(fosterKnotUrl()).toBe(""); expect(fosterKnotUrl(" ")).toBe(""); });
it.each(["https://foster.test/foster", "foster.test"])( "rejects %s at config load instead of quietly routing reads to the origin", (url) => { expect(() => fosterKnotUrl(url)).toThrow(/FOSTER_KNOT_URL/); } );});
describe("resolveConfig metrics export", () => { it("is off unless an endpoint is set, and names the service svfe", () => { expect(resolveConfig({})).toMatchObject({ otlpEndpoint: "", otlpServiceName: "svfe" }); });
it("reads the collector, its login and the resource from the env", () => { expect( resolveConfig({ SVFE_OTLP_ENDPOINT: "https://telemetry.test/", SVFE_OTLP_AUTH: " user:pass ", SVFE_OTLP_SERVICE_NAME: "svfe-prod", OTEL_RESOURCE_ATTRIBUTES: "cloud.region=europe-north1" }) ).toMatchObject({ otlpEndpoint: "https://telemetry.test", otlpAuth: "user:pass", otlpServiceName: "svfe-prod", otlpResourceAttributes: "cloud.region=europe-north1" }); });});