History

Merge remote-tracking branch 'origin/codex/effect-lint-openapi-plugin-tests' into codex/effect-lint-integration

Rhys Sullivan committed 6 months ago

Commit eb2f5a42 parents 60627a9 2cae07e1 file · +25 −23Browse files

Unified · Split

packages/plugins/openapi/src/sdk/plugin.test.ts+25−23
@@ -1,5 +1,5 @@
11 import { expect, layer } from "@effect/vitest";
2−import { Effect, Layer, Schema } from "effect";
2+import { Effect, Layer, Predicate, Schema } from "effect";
33 import { HttpApi, HttpApiBuilder, HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/unstable/httpapi";
44 import { HttpClient, HttpRouter, HttpServerRequest } from "effect/unstable/http";
55 import * as NodeHttpServer from "@effect/platform-node/NodeHttpServer";
@@ -373,8 +373,10 @@ layer(TestLayer)("OpenAPI Plugin", (it) => { · 367 unmodified lines
373373 executor.tools.invoke("noauth.items.listItems", {}, autoApprove),
374374 );
375375
376− expect((error as { _tag: string })._tag).toBe("ToolInvocationError");
377− expect((error as { message: string }).message).toContain("missing-token");
376+ expect(Predicate.isTagged(error, "ToolInvocationError")).toBe(true);
377+ expect(error).toMatchObject({
378+ message: expect.stringContaining("missing-token"),
379+ });
378380 }),
379381 );
380382
@@ -606,7 +608,7 @@ layer(TestLayer)("OpenAPI Plugin", (it) => { · 225 unmodified lines
606608 // Org-level base source
607609 yield* executor.openapi.addSpec({
608610 spec: specJson,
609− scope: ORG_SCOPE as string,
611+ scope: String(ORG_SCOPE),
610612 namespace: "shared",
611613 baseUrl: "",
612614 name: "Org Source",
@@ -615,20 +617,20 @@ layer(TestLayer)("OpenAPI Plugin", (it) => { · 2 unmodified lines
615617 // Per-user shadow with the same namespace
616618 yield* executor.openapi.addSpec({
617619 spec: specJson,
618− scope: USER_SCOPE as string,
620+ scope: String(USER_SCOPE),
619621 namespace: "shared",
620622 name: "User Source",
621623 });
622624
623− const userView = yield* executor.openapi.getSource("shared", USER_SCOPE as string);
624− const orgView = yield* executor.openapi.getSource("shared", ORG_SCOPE as string);
625+ const userView = yield* executor.openapi.getSource("shared", String(USER_SCOPE));
626+ const orgView = yield* executor.openapi.getSource("shared", String(ORG_SCOPE));
625627
626628 // Both rows must coexist — innermost-wins reads come from the
627629 // executor; the store's scope-pinned getters return the exact row.
628630 expect(userView?.name).toBe("User Source");
629− expect(userView?.scope).toBe(USER_SCOPE as string);
631+ expect(userView?.scope).toBe(String(USER_SCOPE));
630632 expect(orgView?.name).toBe("Org Source");
631− expect(orgView?.scope).toBe(ORG_SCOPE as string);
633+ expect(orgView?.scope).toBe(String(ORG_SCOPE));
632634 }),
633635 );
634636
@@ -652,20 +654,20 @@ layer(TestLayer)("OpenAPI Plugin", (it) => { · 17 unmodified lines
652654
653655 yield* executor.openapi.addSpec({
654656 spec: specJson,
655− scope: ORG_SCOPE as string,
657+ scope: String(ORG_SCOPE),
656658 namespace: "shared",
657659 baseUrl: "https://org.example.com",
658660 name: "Org Source",
659661 });
660662 yield* executor.openapi.addSpec({
661663 spec: specJson,
662− scope: USER_SCOPE as string,
664+ scope: String(USER_SCOPE),
663665 namespace: "shared",
664666 name: "User Source",
665667 });
666668
667669 findManyCalls.length = 0;
668− const userView = yield* executor.openapi.getSource("shared", USER_SCOPE as string);
670+ const userView = yield* executor.openapi.getSource("shared", String(USER_SCOPE));
669671
670672 expect(userView?.config.baseUrl).toBe("https://org.example.com");
671673 expect(findManyCalls.some((call) => call.model === "openapi_source")).toBe(false);
@@ -689,23 +691,23 @@ layer(TestLayer)("OpenAPI Plugin", (it) => { · 17 unmodified lines
689691
690692 yield* executor.openapi.addSpec({
691693 spec: specJson,
692− scope: ORG_SCOPE as string,
694+ scope: String(ORG_SCOPE),
693695 namespace: "shared",
694696 baseUrl: "",
695697 name: "Org Source",
696698 });
697699 yield* executor.openapi.addSpec({
698700 spec: specJson,
699− scope: USER_SCOPE as string,
701+ scope: String(USER_SCOPE),
700702 namespace: "shared",
701703 baseUrl: "",
702704 name: "User Source",
703705 });
704706
705− yield* executor.openapi.removeSpec("shared", USER_SCOPE as string);
707+ yield* executor.openapi.removeSpec("shared", String(USER_SCOPE));
706708
707− const userView = yield* executor.openapi.getSource("shared", USER_SCOPE as string);
708− const orgView = yield* executor.openapi.getSource("shared", ORG_SCOPE as string);
709+ const userView = yield* executor.openapi.getSource("shared", String(USER_SCOPE));
710+ const orgView = yield* executor.openapi.getSource("shared", String(ORG_SCOPE));
709711
710712 expect(userView).toBeNull();
711713 expect(orgView?.name).toBe("Org Source");
@@ -729,26 +731,26 @@ layer(TestLayer)("OpenAPI Plugin", (it) => { · 17 unmodified lines
729731
730732 yield* executor.openapi.addSpec({
731733 spec: specJson,
732− scope: ORG_SCOPE as string,
734+ scope: String(ORG_SCOPE),
733735 namespace: "shared",
734736 baseUrl: "https://org.example.com",
735737 name: "Org Source",
736738 });
737739 yield* executor.openapi.addSpec({
738740 spec: specJson,
739− scope: USER_SCOPE as string,
741+ scope: String(USER_SCOPE),
740742 namespace: "shared",
741743 baseUrl: "https://user.example.com",
742744 name: "User Source",
743745 });
744746
745− yield* executor.openapi.updateSource("shared", USER_SCOPE as string, {
747+ yield* executor.openapi.updateSource("shared", String(USER_SCOPE), {
746748 name: "User Renamed",
747749 baseUrl: "https://user-new.example.com",
748750 });
749751
750− const userView = yield* executor.openapi.getSource("shared", USER_SCOPE as string);
751− const orgView = yield* executor.openapi.getSource("shared", ORG_SCOPE as string);
752+ const userView = yield* executor.openapi.getSource("shared", String(USER_SCOPE));
753+ const orgView = yield* executor.openapi.getSource("shared", String(ORG_SCOPE));
752754
753755 expect(userView?.name).toBe("User Renamed");
754756 expect(userView?.config.baseUrl).toBe("https://user-new.example.com");
@@ -939,7 +941,7 @@ layer(TestLayer)("OpenAPI Plugin", (it) => { · 184 unmodified lines
939941 const failure = yield* executor.secrets
940942 .remove(SecretId.make("locked"))
941943 .pipe(Effect.flip);
942− expect((failure as { _tag: string })._tag).toBe("SecretInUseError");
944+ expect(Predicate.isTagged(failure, "SecretInUseError")).toBe(true);
943945
944946 // Detach the binding, then remove succeeds.
945947 yield* executor.openapi.removeSourceBinding(