z_11_g_filetest.gno
1.00 Kb ยท 47 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 admin address = "g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj" // @test2
15 title = "Test Thread"
16 body = "Test body"
17 path = "test-board/1"
18)
19
20var (
21 bid boards.ID
22 pid boards.ID
23)
24
25func init() {
26 testing.SetRealm(testing.NewUserRealm(owner))
27 bid = boards2.CreateBoard(cross, "test-board", false)
28 pid = boards2.CreateThread(cross, bid, "Foo", "bar")
29
30 // Invite a member using a role with permission to edit threads
31 boards2.InviteMember(cross, bid, admin, boards2.RoleAdmin)
32}
33
34func main() {
35 testing.SetRealm(testing.NewUserRealm(admin))
36
37 boards2.EditThread(cross, bid, pid, title, body)
38
39 // Render content must contains thread's title and body
40 content := boards2.Render(path)
41 println(strings.HasPrefix(content, "# "+title))
42 println(strings.Contains(content, body))
43}
44
45// Output:
46// true
47// true