Say an account without its time as age unknown, not as two thousand years (issue 160)
mesh/merge-gate head 67d54d9d09b2 merged into trunk 13be75eb65c0 — pass: builds build-agent, mesh-controller, route-proxy → ace, g14, novox, shanks; no bus…
mesh/repo-check head 67d54d9d09b2 merged into trunk 13be75eb65c0 — pass: its merge-check.sh passed
mesh/delivery delivered

This commit is contained in:
jochen
2026-10-12 17:43:38 +02:00
parent 7953d2889d
commit 67d54d9d09
2 changed files with 14 additions and 1 deletions
+6 -1
View File
@@ -24,7 +24,12 @@ func machineLines(a inventory.MachineAccount, had bool, now time.Time) []string
" " + factLine("kernel", orUnsaid(a.Kernel)),
}
}
out := []string{fmt.Sprintf(" what it is made of, as it said %s ago:", roughly(now.Sub(m.ObservedAt)))}
age := roughly(now.Sub(m.ObservedAt)) + " ago"
if m.ObservedAt.IsZero() {
// Said with no time: its age is not known, and is never read as two thousand years.
age = "at a time it did not say (age unknown)"
}
out := []string{fmt.Sprintf(" what it is made of, as it said %s:", age)}
add := func(name, value string) { out = append(out, " "+factLine(name, value)) }
unknown := map[string]string{}
for k, v := range m.Unknown {
@@ -78,3 +78,11 @@ func TestAnOlderNodeEngineStillShowsArchitectureAndKernel(t *testing.T) {
t.Errorf("%s", got)
}
}
func TestAnAccountWithoutItsTimeSaysAgeUnknown(t *testing.T) {
got := machineLines(inventory.MachineAccount{Architecture: "amd64", Kernel: "linux",
Machine: &inventory.MadeOf{KernelRelease: "7.2"}}, true, time.Now())[0]
if !strings.Contains(got, "age unknown") || strings.Contains(got, "d ago") {
t.Errorf("%s", got)
}
}