Some checks failed
Build & Sign Wraith / Build Windows + Sign (push) Has been cancelled
Go + Wails v3 + Vue 3 + SQLite + FreeRDP3 (purego) 183 tests, 76 source files, 9,910 lines of code Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
73 lines
1.8 KiB
Go
73 lines
1.8 KiB
Go
package ssh
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestProcessOutputBasicOSC7(t *testing.T) {
|
|
tracker := NewCWDTracker()
|
|
input := []byte("hello\033]7;file://myhost/home/user\033\\world")
|
|
cleaned, cwd := tracker.ProcessOutput(input)
|
|
if string(cleaned) != "helloworld" {
|
|
t.Errorf("cleaned = %q", string(cleaned))
|
|
}
|
|
if cwd != "/home/user" {
|
|
t.Errorf("cwd = %q", cwd)
|
|
}
|
|
}
|
|
|
|
func TestProcessOutputBELTerminator(t *testing.T) {
|
|
tracker := NewCWDTracker()
|
|
input := []byte("output\033]7;file://host/tmp\007more")
|
|
cleaned, cwd := tracker.ProcessOutput(input)
|
|
if string(cleaned) != "outputmore" {
|
|
t.Errorf("cleaned = %q", string(cleaned))
|
|
}
|
|
if cwd != "/tmp" {
|
|
t.Errorf("cwd = %q", cwd)
|
|
}
|
|
}
|
|
|
|
func TestProcessOutputNoOSC7(t *testing.T) {
|
|
tracker := NewCWDTracker()
|
|
input := []byte("just normal output")
|
|
cleaned, cwd := tracker.ProcessOutput(input)
|
|
if string(cleaned) != "just normal output" {
|
|
t.Errorf("cleaned = %q", string(cleaned))
|
|
}
|
|
if cwd != "" {
|
|
t.Errorf("cwd should be empty, got %q", cwd)
|
|
}
|
|
}
|
|
|
|
func TestProcessOutputMultipleOSC7(t *testing.T) {
|
|
tracker := NewCWDTracker()
|
|
input := []byte("\033]7;file://h/dir1\033\\text\033]7;file://h/dir2\033\\end")
|
|
cleaned, cwd := tracker.ProcessOutput(input)
|
|
if string(cleaned) != "textend" {
|
|
t.Errorf("cleaned = %q", string(cleaned))
|
|
}
|
|
if cwd != "/dir2" {
|
|
t.Errorf("cwd = %q, want /dir2", cwd)
|
|
}
|
|
}
|
|
|
|
func TestGetCWDPersists(t *testing.T) {
|
|
tracker := NewCWDTracker()
|
|
tracker.ProcessOutput([]byte("\033]7;file://h/home/user\033\\"))
|
|
if tracker.GetCWD() != "/home/user" {
|
|
t.Errorf("GetCWD = %q", tracker.GetCWD())
|
|
}
|
|
}
|
|
|
|
func TestShellIntegrationCommand(t *testing.T) {
|
|
cmd := ShellIntegrationCommand("bash")
|
|
if cmd == "" {
|
|
t.Error("bash command should not be empty")
|
|
}
|
|
cmd = ShellIntegrationCommand("zsh")
|
|
if cmd == "" {
|
|
t.Error("zsh command should not be empty")
|
|
}
|
|
}
|