Files
felhom.eu/hub/internal/osupdates/docker_firstseen_test.go
T

39 lines
1.5 KiB
Go

package osupdates
import (
"testing"
"time"
)
// The Docker set's "first seen" is stamped by the evaluate tick, not by a page view: two healthy night Docker steps that
// happen while nobody opens the System page count. Before 2026-10-05 the stamp was taken only by DockerStatus on the
// page, so nights before the first view were lost (and the page test flaked on a second boundary).
// Red-proof: drop the DockerStatus call from Evaluate — the final status still waits ("0 of 2" / "1 of 2").
func TestEvaluate_StampsDockerFirstSeenWithoutAPageView(t *testing.T) {
f := newFix(t)
f.s.DockerNights = 2
set := []Package{{Name: "docker-ce", Version: "5:29.8.2-1", Origin: "Docker"}}
f.reportL(t, "hp", LayerDocker, "debug", true, set...)
f.reportL(t, "n100", LayerDocker, "debug", true, set...)
f.now = f.now.Add(time.Minute)
if _, err := f.s.Evaluate(); err != nil { // the tick: no page view anywhere in this test
t.Fatal(err)
}
for i := 0; i < 2; i++ {
f.now = f.now.Add(24 * time.Hour)
f.reportL(t, "hp", LayerDocker, "night", true, set...)
f.reportL(t, "n100", LayerDocker, "night", true, set...)
}
f.now = f.now.Add(time.Hour)
st, err := f.s.DockerStatus() // the operator opens the page for the first time only now
if err != nil {
t.Fatal(err)
}
if st.Waiting != "" {
t.Fatalf("two healthy nights after the set was first seen on the tick, yet: %q (first seen %s)", st.Waiting, st.FirstSeen)
}
if st.FirstSeen.IsZero() {
t.Fatalf("no first-seen stamp: %+v", st)
}
}