Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fixing failing goals, cache and token tests #522

Merged
merged 5 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"eslint": "9.13.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.2.1",
"eslint-plugin-vitest": "0.5.4",
"jest": "29.7.0",
"lint-staged": "15.2.10",
"nodemon": "3.1.7",
Expand Down
29 changes: 13 additions & 16 deletions packages/core/src/tests/cache.test.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,41 @@
import { CacheManager, MemoryCacheAdapter } from "../cache.ts"; // Adjust the import based on your project structure
import { CacheManager, MemoryCacheAdapter } from "../cache.ts";
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";

// Now, let’s fix the test suite.

describe.only("CacheManager", () => {
describe("CacheManager", () => {
let cache: CacheManager<MemoryCacheAdapter>;

jest.useFakeTimers();

beforeEach(() => {
vi.useFakeTimers();
cache = new CacheManager(new MemoryCacheAdapter());
jest.setSystemTime(Date.now());
vi.setSystemTime(Date.now());
});

afterEach(() => {
vi.useRealTimers();
});

it("should set/get/delete cache", async () => {
await cache.set("foo", "bar");

expect(await cache.get("foo")).toEqual("bar");

expect(cache.adapter.data.get("foo")).toEqual(
JSON.stringify({ value: "bar", expires: 0 })
);

await cache.delete("foo");

expect(await cache.get("foo")).toEqual(undefined);
expect(cache.adapter.data.get("foo")).toEqual(undefined);
});

it("should set/get/delete cache with expiration", async () => {
const expires = Date.now() + 5 * 1000;
it("should handle expiring cache", async () => {
const expires = Date.now() + 1000;

await cache.set("foo", "bar", { expires: expires });
await cache.set("foo", "bar", { expires });

expect(await cache.get("foo")).toEqual("bar");

expect(cache.adapter.data.get("foo")).toEqual(
JSON.stringify({ value: "bar", expires: expires })
);

jest.setSystemTime(expires + 1000);
vi.setSystemTime(expires + 1000);

expect(await cache.get("foo")).toEqual(undefined);
expect(cache.adapter.data.get("foo")).toEqual(undefined);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/tests/defaultCharacters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe("defaultCharacter", () => {
});

it("should have the correct modelProvider", () => {
expect(defaultCharacter.modelProvider).toBe(ModelProviderName.OPENAI);
expect(defaultCharacter.modelProvider).toBe(ModelProviderName.OLLAMA);
});

it("should have the correct voice model", () => {
Expand Down
Loading
Loading