Skip to content
quarry Artifact [996a2e01e7]
Login

Artifact [996a2e01e7]

Artifact 996a2e01e74dd4efdffb8960be9d69b1ab74e49a17f967d752f617dd4470b14b:


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")
}