Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_8_a_filetest.gno

0.89 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	title         = "Test Thread"
15	body          = "Test body"
16	path          = "test-board/1"
17)
18
19var bid boards.ID
20
21func init() {
22	testing.SetRealm(testing.NewUserRealm(owner))
23	bid = boards2.CreateBoard(cross, "test-board", false)
24}
25
26func main() {
27	testing.SetRealm(testing.NewUserRealm(owner))
28
29	tid := boards2.CreateThread(cross, bid, title, body)
30
31	// Ensure that returned ID is right
32	println(tid == 1)
33
34	// Thread should not be frozen by default
35	println(boards2.IsThreadFrozen(bid, tid))
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// false
46// true
47// true