|
14 | 14 |
|
15 | 15 | import assert from "assert";
|
16 | 16 | import { createAstraUri } from "@/src/collections/utils";
|
| 17 | +import {AstraDB, Client} from "@/src/collections"; |
17 | 18 |
|
18 | 19 | describe("Utils test", () => {
|
19 |
| - it("createProdAstraUri", () => { |
20 |
| - const dbIdUUID = "ddd5843c-3dea-11ee-be56-0242ac120002"; |
21 |
| - const uri: string = createAstraUri(dbIdUUID, "us-east1", "testks1"); |
| 20 | + it("ClientBaseUriTest", () => { |
| 21 | + const apiEndPoint = "https://a5cf1913-b80b-4f44-ab9f-a8b1c98469d0-ap-south-1.apps.astra.datastax.com"; |
| 22 | + const astraDb = new AstraDB("myToken",apiEndPoint,"testks1"); |
22 | 23 | assert.strictEqual(
|
23 |
| - uri, |
24 |
| - "https://" + |
25 |
| - dbIdUUID + |
26 |
| - "-us-east1.apps.astra.datastax.com/api/json/v1/testks1", |
| 24 | + astraDb.httpClient.baseUrl, |
| 25 | + "https://a5cf1913-b80b-4f44-ab9f-a8b1c98469d0-ap-south-1.apps.astra.datastax.com/api/json/v1/testks1", |
27 | 26 | );
|
28 | 27 | });
|
29 |
| - it("createProdAstraUriWithToken", () => { |
30 |
| - const dbIdUUID = "ddd5843c-3dea-11ee-be56-0242ac120002"; |
31 |
| - const uri: string = createAstraUri( |
32 |
| - dbIdUUID, |
33 |
| - "us-east1", |
34 |
| - "testks1", |
35 |
| - "myToken", |
| 28 | + it("ClientBaseUriTestDefaultKeyspace", () => { |
| 29 | + const apiEndPoint = "https://a5cf1913-b80b-4f44-ab9f-a8b1c98469d0-ap-south-1.apps.astra.datastax.com"; |
| 30 | + const astraDb = new AstraDB("myToken",apiEndPoint); |
| 31 | + assert.strictEqual( |
| 32 | + astraDb.httpClient.baseUrl, |
| 33 | + "https://a5cf1913-b80b-4f44-ab9f-a8b1c98469d0-ap-south-1.apps.astra.datastax.com/api/json/v1/default_keyspace", |
36 | 34 | );
|
| 35 | + }); |
| 36 | + it("createProdAstraUri", () => { |
| 37 | + const apiEndPoint = "https://a5cf1913-b80b-4f44-ab9f-a8b1c98469d0-ap-south-1.apps.astra.datastax.com"; |
| 38 | + const uri: string = createAstraUri( apiEndPoint, "testks1"); |
37 | 39 | assert.strictEqual(
|
38 | 40 | uri,
|
39 |
| - "https://" + |
40 |
| - dbIdUUID + |
41 |
| - "-us-east1.apps.astra.datastax.com/api/json/v1/testks1?applicationToken=myToken", |
| 41 | + "https://a5cf1913-b80b-4f44-ab9f-a8b1c98469d0-ap-south-1.apps.astra.datastax.com/api/json/v1/testks1", |
42 | 42 | );
|
43 | 43 | });
|
44 |
| - it("createProdAstraUriWithTokenAndProdEnum", () => { |
45 |
| - const dbIdUUID = "ddd5843c-3dea-11ee-be56-0242ac120002"; |
46 |
| - const uri: string = createAstraUri( |
47 |
| - dbIdUUID, |
48 |
| - "us-east1", |
49 |
| - "testks1", |
50 |
| - "myToken", |
51 |
| - ); |
| 44 | + it("createProdAstraUriWithToken", () => { |
| 45 | + const apiEndPoint = "https://a5cf1913-b80b-4f44-ab9f-a8b1c98469d0-ap-south-1.apps.astra.datastax.com"; |
| 46 | + const uri: string = createAstraUri( apiEndPoint, "testks1", "myToken"); |
52 | 47 | assert.strictEqual(
|
53 |
| - uri, |
54 |
| - "https://" + |
55 |
| - dbIdUUID + |
56 |
| - "-us-east1.apps.astra.datastax.com/api/json/v1/testks1?applicationToken=myToken", |
| 48 | + uri, |
| 49 | + "https://a5cf1913-b80b-4f44-ab9f-a8b1c98469d0-ap-south-1.apps.astra.datastax.com/api/json/v1/testks1?applicationToken=myToken", |
57 | 50 | );
|
58 | 51 | });
|
| 52 | + it("createProdAstraUriWithTokenAndProdEnum", () => { |
| 53 | + const apiEndPoint = "https://a5cf1913-b80b-4f44-ab9f-a8b1c98469d0-ap-south-1.apps.astra.datastax.com"; |
| 54 | + const uri: string = createAstraUri( apiEndPoint, "testks1", "myToken"); |
| 55 | + assert.strictEqual( |
| 56 | + uri, |
| 57 | + "https://a5cf1913-b80b-4f44-ab9f-a8b1c98469d0-ap-south-1.apps.astra.datastax.com/api/json/v1/testks1?applicationToken=myToken", |
| 58 | + ); |
| 59 | + }); |
59 | 60 | it("createProdAstraUriWithTokenAndProdEnumWithBaseAPIPath", () => {
|
60 |
| - const dbIdUUID = "ddd5843c-3dea-11ee-be56-0242ac120002"; |
61 |
| - const uri: string = createAstraUri( |
62 |
| - dbIdUUID, |
63 |
| - "us-east1", |
64 |
| - "testks1", |
65 |
| - "myToken", |
66 |
| - "apis", |
67 |
| - ); |
| 61 | + const apiEndPoint = "https://a5cf1913-b80b-4f44-ab9f-a8b1c98469d0-ap-south-1.apps.astra.datastax.com"; |
| 62 | + const uri: string = createAstraUri( apiEndPoint, "testks1", "myToken","apis"); |
68 | 63 | assert.strictEqual(
|
69 |
| - uri, |
70 |
| - "https://" + |
71 |
| - dbIdUUID + |
72 |
| - "-us-east1.apps.astra.datastax.com/apis/testks1?applicationToken=myToken", |
| 64 | + uri, |
| 65 | + "https://a5cf1913-b80b-4f44-ab9f-a8b1c98469d0-ap-south-1.apps.astra.datastax.com/apis/testks1?applicationToken=myToken", |
73 | 66 | );
|
74 | 67 | });
|
75 | 68 | });
|
0 commit comments