-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
48f4af8
commit e20f705
Showing
9 changed files
with
70 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { describe, expect, test } from "bun:test"; | ||
import { ResetCommand } from "."; | ||
import { newHttpClient, randomFloat, randomID } from "../../../utils/test-utils"; | ||
import { FetchCommand } from "../fetch"; | ||
import { UpsertCommand } from "../upsert"; | ||
|
||
const client = newHttpClient(); | ||
|
||
describe("RESET", () => { | ||
test("should flush indexes successfully", async () => { | ||
const randomizedData = new Array(20) | ||
.fill("") | ||
.map(() => ({ id: randomID(), vector: [randomFloat(), randomFloat()] })); | ||
|
||
const payloads = randomizedData.map((data) => new UpsertCommand(data).exec(client)); | ||
|
||
await Promise.all(payloads); | ||
|
||
const res = await new FetchCommand({ | ||
ids: randomizedData.map((x) => x.id), | ||
includeVectors: true, | ||
}).exec(client); | ||
|
||
expect(res).toEqual(randomizedData); | ||
|
||
await new ResetCommand().exec(client); | ||
const resAfterReset = await new FetchCommand({ | ||
ids: randomizedData.map((x) => x.id), | ||
includeVectors: true, | ||
}).exec(client); | ||
|
||
expect(resAfterReset).toEqual(new Array(20).fill(null)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Command } from "../../index"; | ||
|
||
export class ResetCommand extends Command<string> { | ||
constructor() { | ||
super([], "reset"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters