mirror of
https://github.com/stablyai/orca.git
synced 2026-11-18 20:06:10 +00:00
orca server ... replaces orca environment ... and orca host name; --server and --parent-server replace --environment and --parent-environment. Old spellings stay accepted as input only: help, suggestions, errors and printed commands use the new names, and giving both spellings different values is invalid_argument. --host is still parsed but leaves help; orca host list/rm are hidden. Listings name each row's owning server (server: / server=) from data already returned, mapping a stored owner to a saved-server name only from this computer's own store, and print server=unknown instead of guessing local. The ports footer and search hits drop host=. CLI-built JSON uses server keys (server, address.server, parent.server, unknown-server, servers, knownServers, status target kind server). create/set print the same parent line as ps.
84 lines
2.5 KiB
TypeScript
84 lines
2.5 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest'
|
|
|
|
const {
|
|
callMock,
|
|
runtimeClientConstructorMock,
|
|
serveOrcaAppMock,
|
|
getDefaultUserDataPathMock,
|
|
addEnvironmentFromPairingCodeMock,
|
|
listEnvironmentsMock,
|
|
spawnMock
|
|
} = vi.hoisted(() => ({
|
|
callMock: vi.fn(),
|
|
runtimeClientConstructorMock: vi.fn(),
|
|
serveOrcaAppMock: vi.fn(),
|
|
getDefaultUserDataPathMock: vi.fn(() => '/tmp/orca-user-data'),
|
|
addEnvironmentFromPairingCodeMock: vi.fn(),
|
|
listEnvironmentsMock: vi.fn(),
|
|
spawnMock: vi.fn()
|
|
}))
|
|
|
|
vi.mock('./runtime-client', async () => {
|
|
const { createRuntimeClientModuleMock } = await import('./index-test-harness.js')
|
|
return createRuntimeClientModuleMock({
|
|
callMock,
|
|
runtimeClientConstructorMock,
|
|
serveOrcaAppMock,
|
|
getDefaultUserDataPathMock
|
|
})
|
|
})
|
|
|
|
vi.mock('./runtime/environments', () => ({
|
|
addEnvironmentFromPairingCode: addEnvironmentFromPairingCodeMock,
|
|
removeEnvironment: vi.fn(),
|
|
resolveEnvironment: vi.fn()
|
|
}))
|
|
|
|
vi.mock('../shared/remote-runtime/host-store/runtime-environment-store', () => ({
|
|
listEnvironments: listEnvironmentsMock
|
|
}))
|
|
|
|
vi.mock('child_process', async () => {
|
|
const { createChildProcessModuleMock } = await import('./index-test-harness.js')
|
|
return createChildProcessModuleMock(spawnMock)
|
|
})
|
|
|
|
import { main } from './index'
|
|
import { useWorktreeAwarenessEnvironment } from './index-test-harness'
|
|
|
|
describe('orca cli worktree awareness', () => {
|
|
useWorktreeAwarenessEnvironment({
|
|
callMock,
|
|
serveOrcaAppMock,
|
|
getDefaultUserDataPathMock,
|
|
addEnvironmentFromPairingCodeMock,
|
|
listEnvironmentsMock,
|
|
spawnMock
|
|
})
|
|
|
|
it('lists saved servers under the old spelling even when ORCA_ENVIRONMENT is set', async () => {
|
|
process.env.ORCA_ENVIRONMENT = 'stale-env'
|
|
listEnvironmentsMock.mockReturnValue([addEnvironmentFromPairingCodeMock()])
|
|
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {})
|
|
|
|
await main(['environment', 'list', '--json'], '/tmp/repo')
|
|
|
|
expect(listEnvironmentsMock).toHaveBeenCalledWith('/tmp/orca-user-data')
|
|
expect(callMock).not.toHaveBeenCalled()
|
|
expect(JSON.parse(String(logSpy.mock.calls[0]?.[0]))).toMatchObject({
|
|
ok: true,
|
|
result: {
|
|
servers: [
|
|
{
|
|
id: 'env-1',
|
|
name: 'desk',
|
|
endpoints: [{ id: 'ws-env-1', kind: 'websocket', endpoint: 'ws://127.0.0.1:6768' }]
|
|
}
|
|
]
|
|
}
|
|
})
|
|
expect(logSpy.mock.calls[0]?.[0]).not.toContain('token')
|
|
expect(logSpy.mock.calls[0]?.[0]).not.toContain('publicKeyB64')
|
|
})
|
|
})
|