z_8_a_filetest.gno

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