Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_flag_thread_06_filetest.gno

1.16 Kb · 45 lines
 1// PKGPATH: gno.land/r/gnoland/boards2/v1/filetests/z_flag_thread_06_filetest
 2
 3package z_flag_thread_06_filetest
 4
 5import (
 6	"testing"
 7
 8	"gno.land/p/gnoland/boards"
 9
10	boards2 "gno.land/r/gnoland/boards2/v1"
11)
12
13const (
14	owner     address = "g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh"
15	moderator address = "g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj" // @test2
16)
17
18var (
19	bid boards.ID
20	pid boards.ID
21)
22
23func init(cur realm) {
24	// Created a board with a specific flagging threshold
25	testing.SetRealm(testing.NewUserRealm(owner))
26	bid = boards2.CreateBoard(cross(cur), "test-board", false, false)
27	boards2.SetFlaggingThreshold(cross(cur), bid, 2)
28
29	// Invite a moderator to the new board
30	boards2.InviteMember(cross(cur), bid, moderator, boards2.RoleModerator)
31
32	// Create a new thread and flag it as a moderator
33	testing.SetRealm(testing.NewUserRealm(moderator))
34	pid = boards2.CreateThread(cross(cur), bid, "Foo", "bar")
35	boards2.FlagThread(cross(cur), bid, pid, "Reason")
36}
37
38func main(cur realm) {
39	testing.SetRealm(testing.NewUserRealm(moderator))
40
41	boards2.FlagThread(cross(cur), bid, pid, "Reason")
42}
43
44// Error:
45// post has been already flagged by g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj