Unified · Split
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | import { describe, expect, it } from "@effect/vitest"; |
| 2 | −import { Deferred, Effect, Fiber } from "effect"; | |
| 2 | +import { Deferred, Effect, Exit, Fiber, Predicate } from "effect"; | |
| 3 | 3 | |
| 4 | 4 | import { makeMemoryAdapter } from "@executor-js/storage-core/testing/memory"; |
| 5 | 5 | |
| @@ -162,7 +162,9 @@ describe("connections", () => { · 156 unmodified lines | ||
| 162 | 162 | }), |
| 163 | 163 | ) |
| 164 | 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 | 282 | const err = yield* executor.secrets |
| 281 | 283 | .remove("conn-1.access") |
| 282 | 284 | .pipe(Effect.flip); |
| 283 | − expect((err as { _tag: string })._tag).toBe( | |
| 284 | − "SecretOwnedByConnectionError", | |
| 285 | + expect(Predicate.isTagged(err, "SecretOwnedByConnectionError")).toBe( | |
| 286 | + true, | |
| 285 | 287 | ); |
| 286 | 288 | }), |
| 287 | 289 | ); |
| @@ -553,10 +555,10 @@ describe("connections", () => { · 265 unmodified lines | ||
| 553 | 555 | { concurrency: "unbounded" }, |
| 554 | 556 | ); |
| 555 | 557 | 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"); | |
| 560 | 562 | } |
| 561 | 563 | expect(calls).toHaveLength(1); |
| 562 | 564 | }), |
| @@ -610,8 +612,12 @@ describe("connections", () => { · 47 unmodified lines | ||
| 610 | 612 | const flipped = yield* executor.connections |
| 611 | 613 | .accessToken("conn-1") |
| 612 | 614 | .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 | + } | |
| 615 | 621 | expect(flipped.provider).toBe("spotify"); |
| 616 | 622 | expect(flipped.message).toMatch(/invalid_grant/); |
| 617 | 623 | }), |
| @@ -666,7 +672,7 @@ describe("connections", () => { · 48 unmodified lines | ||
| 666 | 672 | const err = yield* executor.connections |
| 667 | 673 | .accessToken("conn-1") |
| 668 | 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 | 708 | const err = yield* executor.connections |
| 703 | 709 | .accessToken("conn-1") |
| 704 | 710 | .pipe(Effect.flip); |
| 705 | − expect((err as { _tag: string })._tag).toBe( | |
| 706 | − "ConnectionRefreshNotSupportedError", | |
| 707 | − ); | |
| 711 | + expect( | |
| 712 | + Predicate.isTagged(err, "ConnectionRefreshNotSupportedError"), | |
| 713 | + ).toBe(true); | |
| 708 | 714 | }), |
| 709 | 715 | ); |
| 710 | 716 | |
| @@ -721,9 +727,7 @@ describe("connections", () => { · 10 unmodified lines | ||
| 721 | 727 | const err = yield* executor.connections |
| 722 | 728 | .accessToken("does-not-exist") |
| 723 | 729 | .pipe(Effect.flip); |
| 724 | − expect((err as { _tag: string })._tag).toBe( | |
| 725 | − "ConnectionNotFoundError", | |
| 726 | − ); | |
| 730 | + expect(Predicate.isTagged(err, "ConnectionNotFoundError")).toBe(true); | |
| 727 | 731 | }), |
| 728 | 732 | ); |
| 729 | 733 | |
| @@ -809,7 +813,7 @@ describe("connections", () => { · 79 unmodified lines | ||
| 809 | 813 | }), |
| 810 | 814 | ) |
| 811 | 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 | 863 | const err = yield* executor.connections |
| 860 | 864 | .setIdentityLabel("does-not-exist", "x") |
| 861 | 865 | .pipe(Effect.flip); |
| 862 | − expect((err as { _tag: string })._tag).toBe( | |
| 863 | − "ConnectionNotFoundError", | |
| 864 | − ); | |
| 866 | + expect(Predicate.isTagged(err, "ConnectionNotFoundError")).toBe(true); | |
| 865 | 867 | }), |
| 866 | 868 | ); |
| 867 | 869 | |