Skip to content
quarry Artifact [2eead87e0f]
Login

Artifact [2eead87e0f]

Artifact 2eead87e0fd53193673a0932e63435188a84eca5cc8e241dca573dd2f8c989b9:


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)
	}
	ix.invalidateCounts()
	if c, err := ix.Counts(false); err != nil || c.Tags != 1 {
		t.Errorf("FAIL: the stats bar counts %d tags (%v), want 1", c.Tags, err)
	}
	t.Log("ok")
}