package backupgood import ( "encoding/json" "testing" "time" ) // Restic's last good night per item, keyed as a disk-load reading is. func TestALastGoodNightIsReadBackAndAnotherVersionRefused(t *testing.T) { at := time.Date(2026, 10, 29, 12, 0, 0, 0, time.UTC) goodRow, _ := json.Marshal(GoodRow{V: GoodVersion, Node: "ace", Module: "pg", Item: "data", CoveredBy: "/srv/pg", LastGood: at}) if g, err := DecodeGoodRow(goodRow); err != nil || !g.LastGood.Equal(at) || GoodKey("ace", "pg", "data") != "ace.pg.data" || GoodBucket != "restic_good" || GoodRead != "restic.good" { t.Fatalf("a last good night read back as %+v: %v", g, err) } if _, err := DecodeGoodRow([]byte(`{"v":2}`)); err == nil { t.Fatal("a last good night of another version was read") } }