unarr/internal/cmd/config_menu_test.go
Deivid Soto 3e0f3a5a64
Some checks failed
Release / release (push) Failing after 0s
Release / docker (push) Has been skipped
Release / virustotal (push) Failing after 0s
feat(cli): upgrade command, rich status, and version cache
- 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
2026-03-31 22:05:43 +02:00

55 lines
1,021 B
Go

package cmd
import "testing"
func TestValidateSpeed(t *testing.T) {
tests := []struct {
input string
wantErr bool
}{
{"", false},
{"0", false},
{" ", false},
{"10MB", false},
{"500KB", false},
{"1GB", false},
{"abc", true},
{"10XB", true},
{"-5MB", true},
}
for _, tt := range tests {
t.Run(tt.input, func(t *testing.T) {
err := validateSpeed(tt.input)
if (err != nil) != tt.wantErr {
t.Errorf("validateSpeed(%q) error = %v, wantErr %v", tt.input, err, tt.wantErr)
}
})
}
}
func TestValidateDuration(t *testing.T) {
tests := []struct {
input string
wantErr bool
}{
{"", false},
{"30s", false},
{"1m", false},
{"5m", false},
{"1h", false},
{"2h30m", false},
{"abc", true},
{"30", true},
{"5x", true},
}
for _, tt := range tests {
t.Run(tt.input, func(t *testing.T) {
err := validateDuration(tt.input)
if (err != nil) != tt.wantErr {
t.Errorf("validateDuration(%q) error = %v, wantErr %v", tt.input, err, tt.wantErr)
}
})
}
}