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