mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
test: no casts in the remote-sleep tests' mock state
This commit is contained in:
@@ -3,10 +3,8 @@
|
||||
// returning the stale record, and only a resume that ran counts as a quiet wake that woke it.
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const state = vi.hoisted(() => ({
|
||||
record: {} as Record<string, unknown>,
|
||||
asleep: false
|
||||
}))
|
||||
type MockState = { record: Record<string, unknown>; asleep: boolean }
|
||||
const state = vi.hoisted((): MockState => ({ record: {}, asleep: false }))
|
||||
const mocks = vi.hoisted(() => ({
|
||||
resume: vi.fn(async () => ({
|
||||
ok: true,
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const state = vi.hoisted(() => ({
|
||||
records: [] as Record<string, unknown>[],
|
||||
updates: [] as { id: string; patch: Record<string, unknown> }[]
|
||||
}))
|
||||
type MockState = {
|
||||
records: Record<string, unknown>[]
|
||||
updates: { id: string; patch: Record<string, unknown> }[]
|
||||
}
|
||||
const state = vi.hoisted((): MockState => ({ records: [], updates: [] }))
|
||||
vi.mock('../../shared/ephemeral-vm-runtime-store', () => ({
|
||||
listEphemeralVmRuntimes: () => state.records,
|
||||
updateEphemeralVmRuntimeStatus: (_path: string, id: string, patch: Record<string, unknown>) => {
|
||||
@@ -38,8 +39,8 @@ const RUNNING = {
|
||||
recipe: { provider: 'orca-cloud' },
|
||||
recipeResult: { sandboxId: 'sbx_1' }
|
||||
}
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: only the fields read here.
|
||||
const record = (patch: Record<string, unknown> = {}) =>
|
||||
const record = (patch: Record<string, unknown> = {}): EphemeralVmRuntimeRecord =>
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the module under test reads only id, status, updatedAt and recipe.provider.
|
||||
({ ...RUNNING, ...patch }) as unknown as EphemeralVmRuntimeRecord
|
||||
|
||||
describe('a cloud VM slept from another client', () => {
|
||||
|
||||
Reference in New Issue
Block a user