Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

z_create_reply_09_filetest.gno

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