z_8_a_filetest.gno
0.85 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 title = "Test Thread"
14 body = "Test body"
15 path = "test-board/1"
16)
17
18var bid boards2.BoardID
19
20func init() {
21 testing.SetRealm(std.NewUserRealm(owner))
22 bid = boards2.CreateBoard(cross, "test-board", false)
23}
24
25func main() {
26 testing.SetRealm(std.NewUserRealm(owner))
27
28 tid := boards2.CreateThread(cross, bid, title, body)
29
30 // Ensure that returned ID is right
31 println(tid == 1)
32
33 // Thread should not be frozen by default
34 println(boards2.IsThreadFrozen(bid, tid))
35
36 // Render content must contains thread's title and body
37 content := boards2.Render(path)
38 println(strings.HasPrefix(content, "# "+title))
39 println(strings.Contains(content, body))
40}
41
42// Output:
43// true
44// false
45// true
46// true