- Replace `upgrade` stub with real command (alias for `self-update`) - Also register `update` as alias: `unarr update` works too - Rewrite `status` to show full config, disk usage, daemon state, and update availability with colored sections - Add version check cache (1h TTL) so `status` is instant on repeat runs - Guard against division by zero on empty filesystems - Guard against negative durations from clock skew - Guard against stale PID via heartbeat recency check (2 min) - Add comprehensive test coverage across agent, engine, upgrade, usenet, arr, library, mediaserver, and UI packages - Improve Makefile coverage target to exclude cmd/ glue code - Fix stream handler resource cleanup and ffprobe error handling
43 lines
871 B
Go
43 lines
871 B
Go
package cmd
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestExpandHome(t *testing.T) {
|
|
home, _ := os.UserHomeDir()
|
|
|
|
tests := []struct {
|
|
input string
|
|
want string
|
|
}{
|
|
{"~/Documents", home + "/Documents"},
|
|
{"~/", home},
|
|
{"/absolute/path", "/absolute/path"},
|
|
{"relative/path", "relative/path"},
|
|
{"", ""},
|
|
{"~notexpanded", "~notexpanded"},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.input, func(t *testing.T) {
|
|
got := expandHome(tt.input)
|
|
if got != tt.want {
|
|
t.Errorf("expandHome(%q) = %q, want %q", tt.input, got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestDefaultDownloadDir(t *testing.T) {
|
|
dir := defaultDownloadDir()
|
|
if dir == "" {
|
|
t.Error("defaultDownloadDir() returned empty string")
|
|
}
|
|
home, _ := os.UserHomeDir()
|
|
if !strings.HasPrefix(dir, home) {
|
|
t.Errorf("defaultDownloadDir() = %q, expected to start with home dir %q", dir, home)
|
|
}
|
|
}
|