z_2_a_filetest.gno

0.77 Kb ยท 42 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 = "Test comment"
14)
15
16var (
17	bid boards2.BoardID
18	tid 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}
26
27func main() {
28	testing.SetRealm(testing.NewUserRealm(owner))
29
30	rid := boards2.CreateReply(cross, bid, tid, 0, comment)
31
32	// Ensure that returned ID is right
33	println(rid == 2)
34
35	// Render content must contain the reply
36	content := boards2.Render(path)
37	println(strings.Contains(content, "\n> "+comment+"\n"))
38}
39
40// Output:
41// true
42// true