z_11_a_filetest.gno
0.77 Kb ยท 41 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 title = "Test Thread"
13 body = "Test body"
14 path = "test-board/1"
15)
16
17var (
18 bid boards2.BoardID
19 pid boards2.PostID
20)
21
22func init() {
23 testing.SetRealm(testing.NewUserRealm(owner))
24 bid = boards2.CreateBoard(cross, "test-board", false)
25 pid = boards2.CreateThread(cross, bid, "Foo", "bar")
26}
27
28func main() {
29 testing.SetRealm(testing.NewUserRealm(owner))
30
31 boards2.EditThread(cross, bid, pid, title, body)
32
33 // Render content must contains thread's title and body
34 content := boards2.Render(path)
35 println(strings.HasPrefix(content, "# "+title))
36 println(strings.Contains(content, body))
37}
38
39// Output:
40// true
41// true