Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

resolve-executable.test.ts

50 lines1.3 KB

1import { describe, expect, it } from 'vitest'
2import { resolveGrokExecutable } from '../src/process/resolve-executable'
3import type { SandboxHandle } from '@tanstack/ai-sandbox'
4​
5function mockSandbox(
6 exec: SandboxHandle['process']['exec'],
7 provider = 'daytona',
8): SandboxHandle {
9 return {
10 id: 'test',
11 provider,
12 process: { exec, spawn: async () => ({ kill: async () => {} }) },
13 } as unknown as SandboxHandle
15​
16describe('resolveGrokExecutable', () => {
17 it('returns host grok on local-process', async () => {
18 const sandbox = mockSandbox(
19 async () => ({
20 stdout: '',
21 stderr: '',
22 exitCode: 1,
23 }),
24 'local-process',
25 )
26 await expect(resolveGrokExecutable(sandbox)).resolves.toBe('grok')
27 })
28​
29 it('honours an explicit non-default path', async () => {
30 const sandbox = mockSandbox(async () => ({
31 stdout: '',
32 stderr: '',
33 exitCode: 1,
34 }))
35 await expect(resolveGrokExecutable(sandbox, '/opt/grok')).resolves.toBe(
36 '/opt/grok',
37 )
38 })
39​
40 it('probes the sandbox when grok is not on PATH', async () => {
41 const sandbox = mockSandbox(async () => ({
42 stdout: '/home/daytona/.grok/bin/grok',
43 stderr: '',
44 exitCode: 0,
45 }))
46 await expect(resolveGrokExecutable(sandbox)).resolves.toBe(
47 '/home/daytona/.grok/bin/grok',
48 )
49 })
50})