Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

z_flag_thread_05_filetest.gno

1.08 Kb · 43 lines
 1// PKGPATH: gno.land/r/gnoland/boards2/v0/filetests/z_flag_thread_05_filetest
 2
 3package z_flag_thread_05_filetest
 4
 5import (
 6	"testing"
 7
 8	"gno.land/p/gnoland/boards/v0"
 9
10	boards2 "gno.land/r/gnoland/boards2/v0"
11)
12
13const (
14	owner     address = "g1skl80cuz8zq3lul9pgz5pc35l2pfzgxgfpsqkx"
15	moderator address = "g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj" // @test2
16)
17
18var (
19	bid boards.ID
20	pid boards.ID
21)
22
23func init(cur realm) {
24	testing.SetRealm(testing.NewUserRealm(owner))
25	bid = boards2.CreateBoard(cross(cur), "test-board", false, false)
26	pid = boards2.CreateThread(cross(cur), bid, "Foo", "bar")
27
28	// Invite a member using a role with permission to flag threads
29	boards2.InviteMember(cross(cur), bid, moderator, boards2.RoleModerator)
30}
31
32func main(cur realm) {
33	testing.SetRealm(testing.NewUserRealm(moderator))
34
35	// Flag thread as moderator
36	boards2.FlagThread(cross(cur), bid, pid, "Reason")
37
38	// Ensure that original thread content not visible
39	println(boards2.Render("test-board/1"))
40}
41
42// Output:
43// ⚠ Thread has been flagged as [inappropriate](/r/gnoland/boards2/v0:test-board/1/flagging-reasons)