z_2_j_filetest.gno
0.85 Kb ยท 43 lines
1package main
2
3import (
4 "strings"
5 "testing"
6
7 boards2 "gno.land/r/gnoland/boards2/v1"
8)
9
10const (
11 owner = address("g16jpf0puufcpcjkph5nxueec8etpcldz7zwgydq") // @devx
12 path = "test-board/1/2"
13 comment = "Second comment"
14)
15
16var (
17 bid boards2.BoardID
18 tid, rid boards2.PostID
19)
20
21func init() {
22 testing.SetRealm(testing.NewUserRealm(owner))
23 bid = boards2.CreateBoard(cross, "test-board", false)
24 tid = boards2.CreateThread(cross, bid, "Foo", "bar")
25 rid = boards2.CreateReply(cross, bid, tid, 0, "First comment")
26}
27
28func main() {
29 testing.SetRealm(testing.NewUserRealm(owner))
30
31 rid2 := boards2.CreateReply(cross, bid, tid, rid, comment)
32
33 // Ensure that returned ID is right
34 println(rid2 == 3)
35
36 // Render content must contain the sub-reply
37 content := boards2.Render(path)
38 println(strings.Contains(content, "\n> > "+comment+"\n"))
39}
40
41// Output:
42// true
43// true