Skip to content
quarry Artifact [5d47ff0eb2]
Login

Artifact [5d47ff0eb2]

Artifact 5d47ff0eb28b4fe76cad66e3bde9ab823314718be3ea3202079e0bc698237f33:


package web

import "testing"

func TestCommentHTML(t *testing.T) {
	for in, want := range map[string]string{
		"fix [0123abcdef] regression": `fix <a href="/r/tk/info/0123abcdef">0123abcdef</a> regression`,
		"see [0123abcdef|the fix]":    `see <a href="/r/tk/info/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)
		}
	}
}