Files
mesh-catalog/modules/mesh-knowledge/cmd/mesh-knowledge/findings_test.go
T

38 lines
1.0 KiB
Go

package main
import (
"context"
"testing"
"time"
)
// findings answers the whole-set findings kept, or only those naming one record (issue 1069).
func TestFindingsAnswersKeptFindingsOrOnlyTheOneNamingARecord(t *testing.T) {
s := newMemStore()
at := time.Date(2026, 10, 17, 9, 0, 0, 0, time.UTC)
seeded := []Finding{
{Rule: "cited", Records: []string{"ADR 0276"}, Says: "ADR 0276 is accepted and nothing cites it", At: at},
{Rule: "supersession", Records: []string{"ADR 0100", "ADR 0101"}, Says: "ADR 0100 supersedes ADR 0101, which is accepted", At: at},
}
if err := s.SetFindings(context.Background(), seeded); err != nil {
t.Fatal(err)
}
k := &KB{Store: s}
all, err := k.Findings("")
if err != nil {
t.Fatal(err)
}
if all.Count != 2 || len(all.Rows) != 2 {
t.Fatalf("want both findings, got %+v", all)
}
one, err := k.Findings("276")
if err != nil {
t.Fatal(err)
}
if one.Count != 1 || len(one.Rows) != 1 || one.Rows[0].Rule != "cited" {
t.Fatalf("want only the finding naming 0276, got %+v", one)
}
}