History

Merge remote-tracking branch 'origin/codex/effect-lint-core-connections-test' into codex/effect-lint-integration

Rhys Sullivan committed 6 months ago

Commit f089a2d2 parents ed4a5d7 fe37cf11 file · +24 −22Browse files

Unified · Split

packages/core/sdk/src/connections.test.ts+24−22
@@ -1,5 +1,5 @@
11 import { describe, expect, it } from "@effect/vitest";
2−import { Deferred, Effect, Fiber } from "effect";
2+import { Deferred, Effect, Exit, Fiber, Predicate } from "effect";
33
44 import { makeMemoryAdapter } from "@executor-js/storage-core/testing/memory";
55
@@ -162,7 +162,9 @@ describe("connections", () => { · 156 unmodified lines
162162 }),
163163 )
164164 .pipe(Effect.flip);
165− expect(err._tag).toBe("ConnectionProviderNotRegisteredError");
165+ expect(
166+ Predicate.isTagged(err, "ConnectionProviderNotRegisteredError"),
167+ ).toBe(true);
166168 }),
167169 );
168170
@@ -194,7 +196,7 @@ describe("connections", () => { · 25 unmodified lines
194196 }),
195197 ),
196198 );
197− expect(result._tag).toBe("Failure");
199+ expect(Exit.isFailure(result)).toBe(true);
198200 }),
199201 );
200202
@@ -280,8 +282,8 @@ describe("connections", () => { · 79 unmodified lines
280282 const err = yield* executor.secrets
281283 .remove("conn-1.access")
282284 .pipe(Effect.flip);
283− expect((err as { _tag: string })._tag).toBe(
284− "SecretOwnedByConnectionError",
285+ expect(Predicate.isTagged(err, "SecretOwnedByConnectionError")).toBe(
286+ true,
285287 );
286288 }),
287289 );
@@ -553,10 +555,10 @@ describe("connections", () => { · 265 unmodified lines
553555 { concurrency: "unbounded" },
554556 );
555557 expect(leaderResult).toBe("rotated-1");
556− for (const r of followerResults) {
557− expect(r._tag).toBe("Success");
558− if (r._tag !== "Success") continue;
559− expect(r.value).toBe("rotated-1");
558+ for (const result of followerResults) {
559+ expect(Exit.isSuccess(result)).toBe(true);
560+ if (!Exit.isSuccess(result)) continue;
561+ expect(result.value).toBe("rotated-1");
560562 }
561563 expect(calls).toHaveLength(1);
562564 }),
@@ -610,8 +612,12 @@ describe("connections", () => { · 47 unmodified lines
610612 const flipped = yield* executor.connections
611613 .accessToken("conn-1")
612614 .pipe(Effect.flip);
613− expect(flipped._tag).toBe("ConnectionReauthRequiredError");
614− if (flipped._tag !== "ConnectionReauthRequiredError") return;
615+ expect(
616+ Predicate.isTagged(flipped, "ConnectionReauthRequiredError"),
617+ ).toBe(true);
618+ if (!Predicate.isTagged(flipped, "ConnectionReauthRequiredError")) {
619+ return;
620+ }
615621 expect(flipped.provider).toBe("spotify");
616622 expect(flipped.message).toMatch(/invalid_grant/);
617623 }),
@@ -666,7 +672,7 @@ describe("connections", () => { · 48 unmodified lines
666672 const err = yield* executor.connections
667673 .accessToken("conn-1")
668674 .pipe(Effect.flip);
669− expect((err as { _tag: string })._tag).toBe("ConnectionRefreshError");
675+ expect(Predicate.isTagged(err, "ConnectionRefreshError")).toBe(true);
670676 }),
671677 );
672678
@@ -702,9 +708,9 @@ describe("connections", () => { · 29 unmodified lines
702708 const err = yield* executor.connections
703709 .accessToken("conn-1")
704710 .pipe(Effect.flip);
705− expect((err as { _tag: string })._tag).toBe(
706− "ConnectionRefreshNotSupportedError",
707− );
711+ expect(
712+ Predicate.isTagged(err, "ConnectionRefreshNotSupportedError"),
713+ ).toBe(true);
708714 }),
709715 );
710716
@@ -721,9 +727,7 @@ describe("connections", () => { · 10 unmodified lines
721727 const err = yield* executor.connections
722728 .accessToken("does-not-exist")
723729 .pipe(Effect.flip);
724− expect((err as { _tag: string })._tag).toBe(
725− "ConnectionNotFoundError",
726− );
730+ expect(Predicate.isTagged(err, "ConnectionNotFoundError")).toBe(true);
727731 }),
728732 );
729733
@@ -809,7 +813,7 @@ describe("connections", () => { · 79 unmodified lines
809813 }),
810814 )
811815 .pipe(Effect.flip);
812− expect((err as { _tag: string })._tag).toBe("ConnectionNotFoundError");
816+ expect(Predicate.isTagged(err, "ConnectionNotFoundError")).toBe(true);
813817 }),
814818 );
815819
@@ -859,9 +863,7 @@ describe("connections", () => { · 43 unmodified lines
859863 const err = yield* executor.connections
860864 .setIdentityLabel("does-not-exist", "x")
861865 .pipe(Effect.flip);
862− expect((err as { _tag: string })._tag).toBe(
863− "ConnectionNotFoundError",
864− );
866+ expect(Predicate.isTagged(err, "ConnectionNotFoundError")).toBe(true);
865867 }),
866868 );
867869