chore(#1): apply Prettier formatting to all source and test files
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
||||
import { PredictionCache } from '../src/prediction-cache.js';
|
||||
import { PredictionQuery, PredictionResponse } from '../src/types/predictions.js';
|
||||
import { TaskType, Complexity, Provider } from '../src/types/events.js';
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
||||
import { PredictionCache } from "../src/prediction-cache.js";
|
||||
import {
|
||||
PredictionQuery,
|
||||
PredictionResponse,
|
||||
} from "../src/types/predictions.js";
|
||||
import { TaskType, Complexity, Provider } from "../src/types/events.js";
|
||||
|
||||
function makeQuery(overrides: Partial<PredictionQuery> = {}): PredictionQuery {
|
||||
return {
|
||||
task_type: TaskType.IMPLEMENTATION,
|
||||
model: 'claude-3-opus',
|
||||
model: "claude-3-opus",
|
||||
provider: Provider.ANTHROPIC,
|
||||
complexity: Complexity.MEDIUM,
|
||||
...overrides,
|
||||
@@ -26,14 +29,14 @@ function makeResponse(sampleSize = 100): PredictionResponse {
|
||||
metadata: {
|
||||
sample_size: sampleSize,
|
||||
fallback_level: 0,
|
||||
confidence: 'high',
|
||||
confidence: "high",
|
||||
last_updated: new Date().toISOString(),
|
||||
cache_hit: false,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
describe('PredictionCache', () => {
|
||||
describe("PredictionCache", () => {
|
||||
beforeEach(() => {
|
||||
vi.useFakeTimers();
|
||||
});
|
||||
@@ -42,13 +45,13 @@ describe('PredictionCache', () => {
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it('should return null for cache miss', () => {
|
||||
it("should return null for cache miss", () => {
|
||||
const cache = new PredictionCache(60_000);
|
||||
const result = cache.get(makeQuery());
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
it('should return cached prediction on hit', () => {
|
||||
it("should return cached prediction on hit", () => {
|
||||
const cache = new PredictionCache(60_000);
|
||||
const query = makeQuery();
|
||||
const response = makeResponse();
|
||||
@@ -59,7 +62,7 @@ describe('PredictionCache', () => {
|
||||
expect(result).toEqual(response);
|
||||
});
|
||||
|
||||
it('should return null when entry has expired', () => {
|
||||
it("should return null when entry has expired", () => {
|
||||
const cache = new PredictionCache(60_000); // 60s TTL
|
||||
const query = makeQuery();
|
||||
const response = makeResponse();
|
||||
@@ -73,7 +76,7 @@ describe('PredictionCache', () => {
|
||||
expect(cache.get(query)).toBeNull();
|
||||
});
|
||||
|
||||
it('should differentiate queries by all fields', () => {
|
||||
it("should differentiate queries by all fields", () => {
|
||||
const cache = new PredictionCache(60_000);
|
||||
|
||||
const query1 = makeQuery({ task_type: TaskType.IMPLEMENTATION });
|
||||
@@ -88,7 +91,7 @@ describe('PredictionCache', () => {
|
||||
expect(cache.get(query2)?.metadata.sample_size).toBe(200);
|
||||
});
|
||||
|
||||
it('should clear all entries', () => {
|
||||
it("should clear all entries", () => {
|
||||
const cache = new PredictionCache(60_000);
|
||||
cache.set(makeQuery(), makeResponse());
|
||||
cache.set(makeQuery({ task_type: TaskType.TESTING }), makeResponse());
|
||||
@@ -99,7 +102,7 @@ describe('PredictionCache', () => {
|
||||
expect(cache.get(makeQuery())).toBeNull();
|
||||
});
|
||||
|
||||
it('should overwrite existing entry with same query', () => {
|
||||
it("should overwrite existing entry with same query", () => {
|
||||
const cache = new PredictionCache(60_000);
|
||||
const query = makeQuery();
|
||||
|
||||
@@ -110,7 +113,7 @@ describe('PredictionCache', () => {
|
||||
expect(cache.get(query)?.metadata.sample_size).toBe(200);
|
||||
});
|
||||
|
||||
it('should clean expired entry on get', () => {
|
||||
it("should clean expired entry on get", () => {
|
||||
const cache = new PredictionCache(60_000);
|
||||
const query = makeQuery();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user