Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_edit_reply_01_filetest.gno

1.03 Kb · 46 lines
 1// PKGPATH: gno.land/r/gnoland/boards2/v1/filetests/z_edit_reply_01_filetest
 2
 3package z_edit_reply_01_filetest
 4
 5import (
 6	"strings"
 7	"testing"
 8
 9	"gno.land/p/gnoland/boards"
10
11	boards2 "gno.land/r/gnoland/boards2/v1"
12)
13
14const (
15	owner address = "g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh"
16	body          = "Test reply"
17	path          = "test-board/1/2"
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
30	// Create a reply and a sub reply
31	parentRID := boards2.CreateReply(cross(cur), bid, tid, 0, "Parent")
32	rid = boards2.CreateReply(cross(cur), bid, tid, parentRID, "Child")
33}
34
35func main(cur realm) {
36	testing.SetRealm(testing.NewUserRealm(owner))
37
38	boards2.EditReply(cross(cur), bid, tid, rid, body)
39
40	// Render content must contain the modified reply
41	content := boards2.Render(path)
42	println(strings.Contains(content, "\n> > "+body))
43}
44
45// Output:
46// true