zz_links_test.gno
0.83 Kb · 33 lines
1package blog
2
3import (
4 "strings"
5 "testing"
6
7 "gno.land/p/nt/testutils/v0"
8 "gno.land/p/nt/uassert/v0"
9)
10
11// Every link the realm renders names its own absolute path. A dead link here
12// once read /r/REPLACE_ADDR/blog, and a test that only checked "a back link
13// exists" passed against it.
14func TestLinksNameThisRealm(cur realm, t *testing.T) {
15 testing.SetRealm(testing.NewUserRealm(testutils.TestAddress("linker")))
16 id := Publish(cross(cur), "Linked", "body")
17 idx := Render("")
18 uassert.True(t, strings.Contains(idx, "](/r/nym-moultest123/x/daily/blog/v1:/"), idx)
19 page := Render("/" + itoaTest(id))
20 uassert.True(t, strings.Contains(page, "(/r/nym-moultest123/x/daily/blog/v1)"), page)
21}
22
23func itoaTest(n int) string {
24 if n == 0 {
25 return "0"
26 }
27 s := ""
28 for n > 0 {
29 s = string(rune(byte(n%10)+byte(48))) + s
30 n /= 10
31 }
32 return s
33}