Skip to content

Commit ef59c2b

Browse files
committed
fix: update functions test to v2 pattern
1 parent 7efc689 commit ef59c2b

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

cloud/api/functions.test.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { describe, it, expect } from "@effect/vitest";
2+
import { Effect } from "effect";
3+
import { TestApiClient, TestClient } from "@/tests/api";
4+
5+
describe("Functions API", () => {
6+
it.effect("POST /functions - requires API key auth", () =>
7+
Effect.gen(function* () {
8+
const client = yield* TestApiClient;
9+
10+
const result = yield* Effect.either(
11+
client.functions.register({
12+
payload: {
13+
code: "def foo(): pass",
14+
hash: "test-hash",
15+
signature: "def foo()",
16+
signatureHash: "sig-hash",
17+
name: "foo",
18+
},
19+
}),
20+
);
21+
22+
expect(result._tag).toBe("Left");
23+
}).pipe(Effect.provide(TestClient.Default)),
24+
);
25+
26+
it.effect("GET /functions - requires API key auth", () =>
27+
Effect.gen(function* () {
28+
const client = yield* TestApiClient;
29+
30+
const result = yield* Effect.either(
31+
client.functions.list({ urlParams: {} }),
32+
);
33+
34+
expect(result._tag).toBe("Left");
35+
}).pipe(Effect.provide(TestClient.Default)),
36+
);
37+
38+
it.effect("GET /functions/:id - requires API key auth", () =>
39+
Effect.gen(function* () {
40+
const client = yield* TestApiClient;
41+
42+
const result = yield* Effect.either(
43+
client.functions.get({ path: { id: "test-id" } }),
44+
);
45+
46+
expect(result._tag).toBe("Left");
47+
}).pipe(Effect.provide(TestClient.Default)),
48+
);
49+
50+
it.effect("GET /functions/by-hash/:hash - requires API key auth", () =>
51+
Effect.gen(function* () {
52+
const client = yield* TestApiClient;
53+
54+
const result = yield* Effect.either(
55+
client.functions.getByHash({ path: { hash: "test-hash" } }),
56+
);
57+
58+
expect(result._tag).toBe("Left");
59+
}).pipe(Effect.provide(TestClient.Default)),
60+
);
61+
});

0 commit comments

Comments
 (0)