z_10_h_filetest.gno

0.92 Kb ยท 39 lines
 1package main
 2
 3import (
 4	"std"
 5	"testing"
 6
 7	boards2 "gno.land/r/gnoland/boards2/v1"
 8)
 9
10const owner = std.Address("g16jpf0puufcpcjkph5nxueec8etpcldz7zwgydq") // @devx
11
12var (
13	bid boards2.BoardID
14	pid boards2.PostID
15)
16
17func init() {
18	// Created a board with flagging threshold greater than 1
19	testing.SetRealm(std.NewUserRealm(owner))
20	bid = boards2.CreateBoard(cross, "test-board", false)
21	boards2.SetFlaggingThreshold(cross, bid, 2)
22
23	// Create a thread so the realm owner can flag and hide it with a single flag
24	pid = boards2.CreateThread(cross, bid, "Foo", "bar")
25	// Also freeze board to make sure that realm owner can still flag the thread
26	boards2.FreezeBoard(cross, bid)
27}
28
29func main() {
30	testing.SetRealm(std.NewUserRealm(owner))
31
32	boards2.FlagThread(cross, bid, pid, "")
33
34	// Ensure that original thread content not visible
35	println(boards2.Render("test-board/1"))
36}
37
38// Output:
39// Thread with ID: 1 has been flagged as inappropriate