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