-
-
Notifications
You must be signed in to change notification settings - Fork 261
Expand file tree
/
Copy pathqdrant-container.test.ts
More file actions
76 lines (54 loc) · 2.42 KB
/
qdrant-container.test.ts
File metadata and controls
76 lines (54 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { QdrantClient } from "@qdrant/js-client-rest";
import crypto from "crypto";
import path from "path";
import { QdrantContainer } from "./qdrant-container";
describe("QdrantContainer", { timeout: 100_000 }, () => {
// connectQdrantSimple {
it("should connect to the client", async () => {
const container = await new QdrantContainer("qdrant/qdrant:v1.13.4").start();
const client = new QdrantClient({ url: `http://${container.getRestHostAddress()}` });
expect((await client.getCollections()).collections.length).toBe(0);
await container.stop();
});
// }
// connectQdrantWithApiKey {
it("should work with valid API keys", async () => {
const apiKey = crypto.randomUUID();
const container = await new QdrantContainer("qdrant/qdrant:v1.13.4").withApiKey(apiKey).start();
const client = new QdrantClient({ url: `http://${container.getRestHostAddress()}`, apiKey });
expect((await client.getCollections()).collections.length).toBe(0);
await container.stop();
});
// }
it("should fail for invalid API keys", async () => {
const apiKey = crypto.randomUUID();
const container = await new QdrantContainer("qdrant/qdrant:v1.13.4").withApiKey(apiKey).start();
const client = new QdrantClient({
url: `http://${container.getRestHostAddress()}`,
apiKey: "INVALID_KEY_" + crypto.randomUUID(),
});
await expect(client.getCollections()).rejects.toThrow("Unauthorized");
await container.stop();
});
// connectQdrantWithConfig {
it("should work with config files - valid API key", async () => {
const container = await new QdrantContainer("qdrant/qdrant:v1.13.4")
.withConfigFile(path.resolve(__dirname, "test_config.yaml"))
.start();
const client = new QdrantClient({ url: `http://${container.getRestHostAddress()}`, apiKey: "SOME_TEST_KEY" });
expect((await client.getCollections()).collections.length).toBe(0);
await container.stop();
});
// }
it("should work with config files - invalid API key", async () => {
const container = await new QdrantContainer("qdrant/qdrant:v1.13.4")
.withConfigFile(path.resolve(__dirname, "test_config.yaml"))
.start();
const client = new QdrantClient({
url: `http://${container.getRestHostAddress()}`,
apiKey: "INVALID_KEY_" + crypto.randomUUID(),
});
await expect(client.getCollections()).rejects.toThrow("Unauthorized");
await container.stop();
});
});