Files
kandev/apps/backend/internal/agentctl/server/process/testing_helpers.go
T
Carlos Florêncio 3a292098ca fix: auto-start code-server when opening file via VS Code (#368)
fix: correctly open file with vscode if vscode is not started yet
2026-03-05 00:25:34 +00:00

34 lines
919 B
Go

package process
import "time"
// SetVscodeForTest injects a VscodeManager with the given status and port.
// Intended for use in tests where starting a real code-server is not feasible.
func (m *Manager) SetVscodeForTest(status VscodeStatus, port int) {
m.vscodeMu.Lock()
defer m.vscodeMu.Unlock()
m.vscode = &VscodeManager{
status: status,
port: port,
}
}
// SetVscodeTransitionForTest injects a VscodeManager that starts in the given
// status and transitions to VscodeStatusRunning after the specified delay.
// Useful for testing code that calls WaitForRunning.
func (m *Manager) SetVscodeTransitionForTest(initialStatus VscodeStatus, port int, delay time.Duration) {
m.vscodeMu.Lock()
defer m.vscodeMu.Unlock()
vm := &VscodeManager{
status: initialStatus,
port: port,
}
m.vscode = vm
go func() {
time.Sleep(delay)
vm.mu.Lock()
vm.status = VscodeStatusRunning
vm.mu.Unlock()
}()
}