Files
nexus/internal/updater/updater_test.go
T
andy 5e40d06a6c Phase 4: SFTP file browser, SSH config import, and update checking
SFTP file browser:
- Created internal/sftpclient wrapping github.com/pkg/sftp for remote file
  operations (list, stat, mkdir, remove, rename, download, upload, pwd)
- Integrated SFTP into session manager with lazy client creation per session
- Added API methods for all SFTP operations with native file dialogs
- Built SFTPBrowser frontend component — right-side resizable panel with
  breadcrumb navigation, sorted file listing, context actions (download,
  rename, delete), upload, new folder, and custom modal dialogs
- Toggle via Cmd+Shift+F on active SSH sessions
- Auto-refits terminal when panel opens/closes/resizes
- Panel cleaned up automatically when session closes

OpenSSH config import:
- Created internal/sshconfig parser for ~/.ssh/config Host blocks
- Converts to profiles with hostname, port, user, identity file,
  ProxyJump (first hop), ForwardAgent, and Compression support
- Skips wildcard-only hosts and Match blocks
- Import button added to Settings > About tab

Automatic update checking:
- Created internal/updater querying GitHub Releases API
- Simple semver comparison, 10-second timeout
- Dev builds never trigger update prompts
- Check button added to Settings > About tab
2026-04-16 00:00:00 +01:00

67 lines
1.5 KiB
Go

package updater
import (
"strings"
"testing"
)
func TestNormaliseVersion(t *testing.T) {
tests := []struct {
input string
want string
}{
{"v1.2.3", "1.2.3"},
{"1.2.3", "1.2.3"},
{" v0.5.0 ", "0.5.0"},
{"dev", "dev"},
}
for _, tt := range tests {
got := normaliseVersion(tt.input)
if got != tt.want {
t.Errorf("normaliseVersion(%q) = %q, want %q", tt.input, got, tt.want)
}
}
}
func TestIsNewer(t *testing.T) {
tests := []struct {
latest string
current string
want bool
}{
{"1.1.0", "1.0.0", true},
{"2.0.0", "1.9.9", true},
{"1.0.1", "1.0.0", true},
{"1.0.0", "1.0.0", false},
{"0.9.0", "1.0.0", false},
{"1.0.0", "dev", false}, // dev builds ignored
{"1.0.0", "", false}, // empty current ignored
{"1.2", "1.1.0", true}, // fewer parts
{"1.0.0", "1.0.0.1", false},
}
for _, tt := range tests {
t.Run(tt.latest+" vs "+tt.current, func(t *testing.T) {
got := isNewer(tt.latest, tt.current)
if got != tt.want {
t.Errorf("isNewer(%q, %q) = %v, want %v", tt.latest, tt.current, got, tt.want)
}
})
}
}
func TestTruncateNotes(t *testing.T) {
short := "Short note"
if got := truncateNotes(short, 100); got != short {
t.Errorf("expected %q, got %q", short, got)
}
long := strings.Repeat("x", 600)
got := truncateNotes(long, 500)
if !strings.HasSuffix(got, "…") {
t.Error("expected truncated notes to end with ellipsis")
}
if len([]rune(got)) != 501 { // 500 runes + "…"
t.Errorf("expected 501 runes, got %d", len([]rune(got)))
}
}