0.2.72 - Magic button, Next up fixes

This commit is contained in:
ponzischeme89
2026-08-17 11:41:36 +12:00
parent 36cb1324fd
commit 12b27c77c3
2655 changed files with 5435 additions and 254 deletions
+50 -8
View File
@@ -12,12 +12,12 @@ func TestEmbyHealthWaitsForTheThresholdBeforeReportingAnOutage(t *testing.T) {
// One failed probe is a hiccup — a restart, a slow scan. A red bar across somebody's
// film for that is worse than saying nothing.
health.record(false, start.Add(time.Minute))
health.record(false, "", start.Add(time.Minute))
if !health.get().reachable {
t.Fatal("a single failure raised an outage")
}
health.record(false, start.Add(2*time.Minute))
health.record(false, "", start.Add(2*time.Minute))
state := health.get()
if state.reachable {
t.Fatal("two consecutive failures did not raise an outage")
@@ -33,10 +33,10 @@ func TestEmbyHealthRecoversOnTheFirstSuccess(t *testing.T) {
var health embyHealth
start := time.Now().UTC()
health.begin(60*time.Second, start)
health.record(false, start.Add(time.Minute))
health.record(false, start.Add(2*time.Minute))
health.record(false, "", start.Add(time.Minute))
health.record(false, "", start.Add(2*time.Minute))
health.record(true, start.Add(3*time.Minute))
health.record(true, "", start.Add(3*time.Minute))
state := health.get()
if !state.reachable {
t.Fatal("a successful probe did not clear the outage")
@@ -53,7 +53,7 @@ func TestEmbyHealthForgetsIsolatedFailures(t *testing.T) {
start := time.Now().UTC()
health.begin(60*time.Second, start)
for minute := 1; minute <= 10; minute++ {
health.record(minute%2 == 0, start.Add(time.Duration(minute)*time.Minute))
health.record(minute%2 == 0, "", start.Add(time.Duration(minute)*time.Minute))
}
if !health.get().reachable {
t.Fatal("alternating failures were reported as an outage")
@@ -79,8 +79,8 @@ func TestEmbyHealthPayloadCarriesTheRetryInterval(t *testing.T) {
var health embyHealth
start := time.Now().UTC()
health.begin(60*time.Second, start)
health.record(false, start.Add(time.Minute))
health.record(false, start.Add(2*time.Minute))
health.record(false, "", start.Add(time.Minute))
health.record(false, "", start.Add(2*time.Minute))
payload := embyHealthFor(health.get())
if payload.RetrySeconds != 60 {
@@ -93,3 +93,45 @@ func TestEmbyHealthPayloadCarriesTheRetryInterval(t *testing.T) {
t.Error("payload omitted the last probe time the bar counts down from")
}
}
// The About page prints Emby's version beside the gateway's, so it has to survive the
// outage that is exactly when somebody goes looking at that page. A probe that fails
// carries no version, and blanking the last known one would replace a fact that is still
// true with nothing.
func TestEmbyHealthKeepsTheLastKnownVersionThroughAnOutage(t *testing.T) {
var health embyHealth
start := time.Now().UTC()
health.begin(60*time.Second, start)
health.record(true, "4.10.0.21", start.Add(time.Minute))
if got := embyHealthFor(health.get()).Version; got != "4.10.0.21" {
t.Fatalf("version = %q, want the version the probe reported", got)
}
health.record(false, "", start.Add(2*time.Minute))
health.record(false, "", start.Add(3*time.Minute))
payload := embyHealthFor(health.get())
if payload.Reachable {
t.Fatal("the outage was not raised")
}
if payload.Version != "4.10.0.21" {
t.Errorf("version = %q, want it kept through the outage", payload.Version)
}
// And an upgrade is picked up on the probe that sees it.
health.record(true, "4.11.0.1", start.Add(4*time.Minute))
if got := embyHealthFor(health.get()).Version; got != "4.11.0.1" {
t.Errorf("version = %q, want the newly reported one", got)
}
}
// Omitted rather than empty, so a television can tell "no probe has completed yet" from
// "Emby answered without one".
func TestEmbyHealthOmitsAnUnknownVersion(t *testing.T) {
var health embyHealth
start := time.Now().UTC()
health.begin(60*time.Second, start)
if got := embyHealthFor(health.get()).Version; got != "" {
t.Errorf("version = %q, want empty before any probe has answered", got)
}
}