package index
import "testing"
// A tag whose newest row cancels it is no tag, and a propagating alias
// is a branch name, not a release; a plain tag still lists (jva, ^3856).
func TestTagsListsOnlyStandingReleaseTags(t *testing.T) {
ix := openIndex(t)
add := func(src, date, checkin, name, sign string) {
if _, err := ix.db.Exec(`INSERT OR REPLACE INTO checkin_tag (src, date, checkin, name, sign, value)
VALUES (?, ?, ?, ?, ?, '')`, src, date, checkin, name, sign); err != nil {
t.Fatal(err)
}
}
add("a1", "2026-01-01", "c1", "sym-v1", "+")
add("a2", "2026-01-02", "c2", "sym-gone", "+")
add("a3", "2026-01-03", "c2", "sym-gone", "-")
add("a4", "2026-01-04", "c3", "sym-main", "*")
tags, err := ix.Tags(10)
if err != nil {
t.Fatal(err)
}
if len(tags) != 1 || tags[0].Name != "v1" {
t.Errorf("FAIL: tags %+v, want only v1", tags)
}
if n, err := ix.TagCount(); err != nil || n != 1 {
t.Errorf("FAIL: TagCount %d %v, want 1", n, err)
}
t.Log("ok")
}