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 @@
1import { describe, expect, it } from "@effect/vitest";1import { describe, expect, it } from "@effect/vitest";
2import { Deferred, Effect, Fiber } from "effect";2import { Deferred, Effect, Exit, Fiber, Predicate } from "effect";
3 3
4import { makeMemoryAdapter } from "@executor-js/storage-core/testing/memory";4import { makeMemoryAdapter } from "@executor-js/storage-core/testing/memory";
5 5
@@ -162,7 +162,9 @@ describe("connections", () => { · 156 unmodified lines
162 }),162 }),
163 )163 )
164 .pipe(Effect.flip);164 .pipe(Effect.flip);
165 expect(err._tag).toBe("ConnectionProviderNotRegisteredError");165 expect(
166 Predicate.isTagged(err, "ConnectionProviderNotRegisteredError"),
167 ).toBe(true);
166 }),168 }),
167 );169 );
168 170
@@ -194,7 +196,7 @@ describe("connections", () => { · 25 unmodified lines
194 }),196 }),
195 ),197 ),
196 );198 );
197 expect(result._tag).toBe("Failure");199 expect(Exit.isFailure(result)).toBe(true);
198 }),200 }),
199 );201 );
200 202
@@ -280,8 +282,8 @@ describe("connections", () => { · 79 unmodified lines
280 const err = yield* executor.secrets282 const err = yield* executor.secrets
281 .remove("conn-1.access")283 .remove("conn-1.access")
282 .pipe(Effect.flip);284 .pipe(Effect.flip);
283 expect((err as { _tag: string })._tag).toBe(285 expect(Predicate.isTagged(err, "SecretOwnedByConnectionError")).toBe(
284 "SecretOwnedByConnectionError",286 true,
285 );287 );
286 }),288 }),
287 );289 );
@@ -553,10 +555,10 @@ describe("connections", () => { · 265 unmodified lines
553 { concurrency: "unbounded" },555 { concurrency: "unbounded" },
554 );556 );
555 expect(leaderResult).toBe("rotated-1");557 expect(leaderResult).toBe("rotated-1");
556 for (const r of followerResults) {558 for (const result of followerResults) {
557 expect(r._tag).toBe("Success");559 expect(Exit.isSuccess(result)).toBe(true);
558 if (r._tag !== "Success") continue;560 if (!Exit.isSuccess(result)) continue;
559 expect(r.value).toBe("rotated-1");561 expect(result.value).toBe("rotated-1");
560 }562 }
561 expect(calls).toHaveLength(1);563 expect(calls).toHaveLength(1);
562 }),564 }),
@@ -610,8 +612,12 @@ describe("connections", () => { · 47 unmodified lines
610 const flipped = yield* executor.connections612 const flipped = yield* executor.connections
611 .accessToken("conn-1")613 .accessToken("conn-1")
612 .pipe(Effect.flip);614 .pipe(Effect.flip);
613 expect(flipped._tag).toBe("ConnectionReauthRequiredError");615 expect(
614 if (flipped._tag !== "ConnectionReauthRequiredError") return;616 Predicate.isTagged(flipped, "ConnectionReauthRequiredError"),
617 ).toBe(true);
618 if (!Predicate.isTagged(flipped, "ConnectionReauthRequiredError")) {
619 return;
620 }
615 expect(flipped.provider).toBe("spotify");621 expect(flipped.provider).toBe("spotify");
616 expect(flipped.message).toMatch(/invalid_grant/);622 expect(flipped.message).toMatch(/invalid_grant/);
617 }),623 }),
@@ -666,7 +672,7 @@ describe("connections", () => { · 48 unmodified lines
666 const err = yield* executor.connections672 const err = yield* executor.connections
667 .accessToken("conn-1")673 .accessToken("conn-1")
668 .pipe(Effect.flip);674 .pipe(Effect.flip);
669 expect((err as { _tag: string })._tag).toBe("ConnectionRefreshError");675 expect(Predicate.isTagged(err, "ConnectionRefreshError")).toBe(true);
670 }),676 }),
671 );677 );
672 678
@@ -702,9 +708,9 @@ describe("connections", () => { · 29 unmodified lines
702 const err = yield* executor.connections708 const err = yield* executor.connections
703 .accessToken("conn-1")709 .accessToken("conn-1")
704 .pipe(Effect.flip);710 .pipe(Effect.flip);
705 expect((err as { _tag: string })._tag).toBe(711 expect(
706 "ConnectionRefreshNotSupportedError",712 Predicate.isTagged(err, "ConnectionRefreshNotSupportedError"),
707 );713 ).toBe(true);
708 }),714 }),
709 );715 );
710 716
@@ -721,9 +727,7 @@ describe("connections", () => { · 10 unmodified lines
721 const err = yield* executor.connections727 const err = yield* executor.connections
722 .accessToken("does-not-exist")728 .accessToken("does-not-exist")
723 .pipe(Effect.flip);729 .pipe(Effect.flip);
724 expect((err as { _tag: string })._tag).toBe(730 expect(Predicate.isTagged(err, "ConnectionNotFoundError")).toBe(true);
725 "ConnectionNotFoundError",
726 );
727 }),731 }),
728 );732 );
729 733
@@ -809,7 +813,7 @@ describe("connections", () => { · 79 unmodified lines
809 }),813 }),
810 )814 )
811 .pipe(Effect.flip);815 .pipe(Effect.flip);
812 expect((err as { _tag: string })._tag).toBe("ConnectionNotFoundError");816 expect(Predicate.isTagged(err, "ConnectionNotFoundError")).toBe(true);
813 }),817 }),
814 );818 );
815 819
@@ -859,9 +863,7 @@ describe("connections", () => { · 43 unmodified lines
859 const err = yield* executor.connections863 const err = yield* executor.connections
860 .setIdentityLabel("does-not-exist", "x")864 .setIdentityLabel("does-not-exist", "x")
861 .pipe(Effect.flip);865 .pipe(Effect.flip);
862 expect((err as { _tag: string })._tag).toBe(866 expect(Predicate.isTagged(err, "ConnectionNotFoundError")).toBe(true);
863 "ConnectionNotFoundError",
864 );
865 }),867 }),
866 );868 );
867 869