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