Skip to content

Commit

Permalink
[BUG] Fix JS client regression (#2026)
Browse files Browse the repository at this point in the history
Fix regression that stopped running the JS client unit tests during CI.

Both regressions are from a large PR: #1970.
  • Loading branch information
ibratoev committed Apr 19, 2024
1 parent 729e657 commit e3d2b8a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
8 changes: 7 additions & 1 deletion bin/ts-integration-test
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ EOF

trap cleanup EXIT

docker compose -f docker-compose.test.yml up --build -d

export CHROMA_INTEGRATION_TEST_ONLY=1
export CHROMA_API_IMPL=chromadb.api.fastapi.FastAPI
export CHROMA_SERVER_HOST=localhost
Expand All @@ -49,14 +51,18 @@ export CHROMA_SERVER_NOFILE=65535
cd clients/js
# moved off of yarn to npm to fix issues with jackspeak/cliui/string-width versions #1314
npm install

npm run test:run
docker compose down

cd ../..

for auth_type in basic token xtoken; do
echo "Testing $auth_type auth"
setup_auth "$auth_type"
cd clients/js
docker compose --env-file ../../.chroma_env -f ../../docker-compose.test-auth.yml up --build -d
yarn test:run-auth-"$auth_type"
npm run test:run-auth-"$auth_type"
cd ../..
docker compose down
done
2 changes: 1 addition & 1 deletion clients/js/src/ChromaClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class ChromaClient {
basePath: path,
});

this.api = new DefaultApi(apiConfig);
this.api = new DefaultApi(apiConfig, undefined, chromaFetch);
this.api.options = fetchOptions ?? {};

if (auth !== undefined) {
Expand Down
7 changes: 4 additions & 3 deletions clients/js/test/auth.basic.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expect, test } from "@jest/globals";
import { chromaBasic } from "./initClientWithAuth";
import chromaNoAuth from "./initClient";
import { ChromaForbiddenError } from "../src/Errors";

test("it should get the version without auth needed", async () => {
const version = await chromaNoAuth.version();
Expand All @@ -15,9 +16,9 @@ test("it should get the heartbeat without auth needed", async () => {
});

test("it should raise error when non authenticated", async () => {
await expect(chromaNoAuth.listCollections()).rejects.toMatchObject({
status: 403,
});
await expect(chromaNoAuth.listCollections()).rejects.toBeInstanceOf(
ChromaForbiddenError
);
});

test("it should list collections", async () => {
Expand Down
7 changes: 4 additions & 3 deletions clients/js/test/auth.token.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
cloudClient,
} from "./initClientWithAuth";
import chromaNoAuth from "./initClient";
import { ChromaForbiddenError } from "../src/Errors";

test("it should get the version without auth needed", async () => {
const version = await chromaNoAuth.version();
Expand All @@ -20,9 +21,9 @@ test("it should get the heartbeat without auth needed", async () => {
});

test("it should raise error when non authenticated", async () => {
await expect(chromaNoAuth.listCollections()).rejects.toMatchObject({
status: 403,
});
await expect(chromaNoAuth.listCollections()).rejects.toBeInstanceOf(
ChromaForbiddenError
);
});

if (!process.env.XTOKEN_TEST) {
Expand Down

0 comments on commit e3d2b8a

Please sign in to comment.