package main import ( "strings" "testing" stdio "git.novox.be/novox/mesh-sdk/go" ) // fakeReader reads a fakeStore as a verb does. type fakeReader struct{ *fakeStore } func (r fakeReader) History(key string) ([]stdio.StateRevision, error) { e, _ := r.Get(key) if e == nil { return []stdio.StateRevision{}, nil } return []stdio.StateRevision{{Key: key, Value: e.Value, Revision: e.Revision, Op: "put", At: r.at[key]}}, nil } // readerOf is a machine's States over fake states. func readerOf(states *fakeStates) func(string) StateReader { return func(name string) StateReader { return fakeReader{states.store(name)} } } // 1840/AC3: the health is unhealthy naming the size while the node is marked not current, and says nothing of // it once the mark is gone. func TestTheHealthNamesTheSizeWhileTheNodeIsNotCurrent(t *testing.T) { states := &fakeStates{} m := machine(nil, 1000) m.Node, m.States = "node-a", readerOf(states) if _, said := m.InstalledHealth(); said { t.Fatal("a current node's health said something") } states.store(StateInstalled).Put("node-a.not-current", NotCurrent{Bytes: 300000, Since: t0}) states.store(StateInstalled).Put("node-b.not-current", NotCurrent{Bytes: 1, Since: t0}) h, said := m.InstalledHealth() if !said || h.Healthy || !strings.Contains(h.Why, "300000 bytes") || !strings.Contains(h.Why, "2026-10-24 04:00") { t.Fatalf("%+v", h) } states.store(StateInstalled).Delete("node-a.not-current") if _, said := m.InstalledHealth(); said { t.Fatal("the mark is gone and the health still says it") } }