Open History to see the last commit
1import { readFileSync } from 'node:fs'
2
3import { describe, expect, it } from 'vitest'
4
5import { bumpVerifiedAt, observationMatches } from './compare.ts'
6import { probeFactSource, probedRoute, staleProbeCount } from './index.ts'
7import { probeIsStale } from './types.ts'
8
9describe('probe records', () => {
10 it('binds only the exact probed model to generateContent', () => {
11 expect(probedRoute('opencode-go', 'gemini-4-argon-contributor')).toBe(
12 'inference/go/google/v1beta/models/gemini-4-argon-contributor:generateContent',
13 )
14 expect(probedRoute('opencode-go', 'gemini')).toBeNull()
15 expect(probedRoute('opencode-go', 'gemini-4-argon')).toBeNull()
16 expect(
17 probeFactSource(
18 'opencode-go',
19 'gemini-4-argon-contributor',
20 'inference/go/google/v1beta/models/gemini-4-argon-contributor:generateContent',
21 ),
22 ).toEqual({
23 derivation: 'probe-verified',
24 verifiedAt: '2026-10-23',
25 sourceUrl:
26 'src/server/providers/probes/opencode-go.ts#gemini-4-argon-contributor-generate',
27 })
28 })
29
30 it('counts a record only after 90 days', () => {
31 expect(
32 probeIsStale('2026-10-23', new Date('2027-01-21T00:00:00.000Z')),
33 ).toBe(false)
34 expect(
35 probeIsStale('2026-10-23', new Date('2027-01-22T00:00:00.000Z')),
36 ).toBe(true)
37 expect(
38 staleProbeCount('opencode-go', new Date('2026-10-23T12:00:00.000Z')),
39 ).toBe(0)
40 expect(
41 staleProbeCount('opencode-go', new Date('2027-01-22T00:00:00.000Z')),
42 ).toBe(2)
43 })
44
45 it('bumps one record date and reports a mismatched body', () => {
46 const source = readFileSync(
47 new URL('./opencode-go.ts', import.meta.url),
48 'utf8',
49 )
50 const next = bumpVerifiedAt(
51 source,
52 'gemini-4-argon-contributor-stream',
53 '2026-11-01',
54 )
55 expect(next).toContain("verifiedAt: '2026-11-01'")
56 expect(next).toContain("verifiedAt: '2026-10-23'")
57 expect(
58 observationMatches(
59 { status: 200, jsonKeys: ['candidates'] },
60 { status: 200, payloads: [{ candidates: [] }] },
61 ),
62 ).toBeNull()
63 expect(
64 observationMatches(
65 { status: 200, jsonKeys: ['candidates'], sse: true },
66 { status: 400, payloads: [] },
67 ),
68 ).toBe('status 400, expected 200')
69 })
70})