Skip to content
quarry Artifact [3f3c3fd8cf]
Login

Artifact [3f3c3fd8cf]

Artifact 3f3c3fd8cf5f9db99d6d199b536b602f89909201af38ce73af8ef5581668f8ce:


package web

import (
	"strings"
	"testing"
)

// Comments as sqlite writes them, against what sqlite.org/src/timeline
// shows: an interwiki link reads as its label (the repository's tag map
// is not carried by a mirror yet), the bar's spaces are fossil's to
// trim, and a character reference reads as its character.
func TestCommentsReadAsFossilShowsThem(t *testing.T) {
	for _, c := range []struct{ in, want, not string }{
		{"Fixes. [bugs:/info/2026-10-28T05:04:51Z|Bug 2026-10-28T05:04:51Z]", "Fixes. Bug 2026-10-28T05:04:51Z", "bugs:/info"},
		{"Report [bugs:/info/2026-10-26T12:54:00Z | 2026-10-26T12:54:00Z].", "Report 2026-10-26T12:54:00Z.", "|"},
		{"and reported by [bugs:/forumpost/70e3174f54|a follow-up comment] to", "and reported by a follow-up comment to", "forumpost"},
		{"works for 0.0<B<1.0.", "works for 0.0<B<1.0.", "<"},
	} {
		got := string(commentHTML("sqlite", c.in))
		if !strings.Contains(got, c.want) || strings.Contains(got, c.not) {
			t.Errorf("FAIL: %q rendered %q, want it to contain %q and not %q", c.in, got, c.want, c.not)
		}
	}
	// A link quarry does resolve is still a link.
	if got := string(commentHTML("sqlite", "see [https://sqlite.org/forum | the forum]")); !strings.Contains(got, `<a href="https://sqlite.org/forum">the forum</a>`) {
		t.Errorf("FAIL: an http link with a spaced bar rendered %q", got)
	}
}