- 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
50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
package engine
|
|
|
|
import "testing"
|
|
|
|
func TestDownloadMethodConstants(t *testing.T) {
|
|
if MethodTorrent != "torrent" {
|
|
t.Errorf("MethodTorrent = %q, want torrent", MethodTorrent)
|
|
}
|
|
if MethodDebrid != "debrid" {
|
|
t.Errorf("MethodDebrid = %q, want debrid", MethodDebrid)
|
|
}
|
|
if MethodUsenet != "usenet" {
|
|
t.Errorf("MethodUsenet = %q, want usenet", MethodUsenet)
|
|
}
|
|
}
|
|
|
|
func TestProgressStruct(t *testing.T) {
|
|
p := Progress{
|
|
DownloadedBytes: 1024,
|
|
TotalBytes: 2048,
|
|
SpeedBps: 512,
|
|
ETA: 10,
|
|
Peers: 5,
|
|
Seeds: 3,
|
|
FileName: "movie.mkv",
|
|
}
|
|
|
|
if p.DownloadedBytes != 1024 {
|
|
t.Errorf("DownloadedBytes = %d, want 1024", p.DownloadedBytes)
|
|
}
|
|
if p.FileName != "movie.mkv" {
|
|
t.Errorf("FileName = %q, want movie.mkv", p.FileName)
|
|
}
|
|
}
|
|
|
|
func TestResultStruct(t *testing.T) {
|
|
r := Result{
|
|
FilePath: "/downloads/movie.mkv",
|
|
FileName: "movie.mkv",
|
|
Method: MethodTorrent,
|
|
Size: 1073741824,
|
|
}
|
|
|
|
if r.Method != MethodTorrent {
|
|
t.Errorf("Method = %q, want torrent", r.Method)
|
|
}
|
|
if r.Size != 1073741824 {
|
|
t.Errorf("Size = %d, want 1073741824", r.Size)
|
|
}
|
|
}
|