Skip to content
quarry Artifact [49e2e2fbbc]
Login

Artifact [49e2e2fbbc]

Artifact 49e2e2fbbc2f0095d0662c5a9a0a567e5d9fea8bdc7e6b7ada8025afbbb12a1b:


package web

import "testing"

func TestCommentHTML(t *testing.T) {
	for in, want := range map[string]string{
		"fix [0123abcdef] regression": `fix <a href="/r/tk/checkin/0123abcdef">0123abcdef</a> regression`,
		"see [0123abcdef|the fix]":    `see <a href="/r/tk/checkin/0123abcdef">the fix</a>`,
		"per [https://x.test/a|docs]": `per <a href="https://x.test/a">docs</a>`,
		"read [Release Notes]":        `read [Release Notes]`,
		"a <b> & [c|<d>]":             `a &lt;b&gt; &amp; [c|&lt;d&gt;]`,
		"case[0] in code":             `case[0] in code`,
		"empty [] brackets":           `empty [] brackets`,
	} {
		if got := string(commentHTML("tk", in)); got != want {
			t.Errorf("commentHTML(%q)\n got  %s\n want %s", in, got, want)
		}
	}
}