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