Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_11_a_filetest.gno

0.81 Kb ยท 43 lines
 1package main
 2
 3import (
 4	"strings"
 5	"testing"
 6
 7	"gno.land/p/gnoland/boards"
 8
 9	boards2 "gno.land/r/boards000/v1rc1"
10)
11
12const (
13	owner address = "g16jpf0puufcpcjkph5nxueec8etpcldz7zwgydq" // @devx
14	title         = "Test Thread"
15	body          = "Test body"
16	path          = "test-board/1"
17)
18
19var (
20	bid boards.ID
21	pid boards.ID
22)
23
24func init() {
25	testing.SetRealm(testing.NewUserRealm(owner))
26	bid = boards2.CreateBoard(cross, "test-board", false)
27	pid = boards2.CreateThread(cross, bid, "Foo", "bar")
28}
29
30func main() {
31	testing.SetRealm(testing.NewUserRealm(owner))
32
33	boards2.EditThread(cross, bid, pid, title, body)
34
35	// Render content must contains thread's title and body
36	content := boards2.Render(path)
37	println(strings.HasPrefix(content, "# "+title))
38	println(strings.Contains(content, body))
39}
40
41// Output:
42// true
43// true