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_ui_thread_05_filetest.gno

0.96 Kb · 39 lines
 1// PKGPATH: gno.land/r/gnoland/boards2/v0/filetests/z_ui_thread_05_filetest
 2
 3// Render thread which has been flagged.
 4package z_ui_thread_05_filetest
 5
 6import (
 7	"testing"
 8
 9	"gno.land/p/gnoland/boards/v0"
10
11	boards2 "gno.land/r/gnoland/boards2/v0"
12)
13
14const (
15	owner     address = "g1skl80cuz8zq3lul9pgz5pc35l2pfzgxgfpsqkx"
16	boardName         = "BoardName"
17)
18
19var threadID boards.ID
20
21func init(cur realm) {
22	testing.SetRealm(testing.NewUserRealm(owner))
23
24	// Create a readonly board and then add a thread
25	boardID := boards2.CreateBoard(cross(cur), boardName, false, false)
26	threadID = boards2.CreateThread(cross(cur), boardID, "Foo", "Body")
27
28	// Flag the thread
29	boards2.SetFlaggingThreshold(cross(cur), boardID, 1)
30	boards2.FlagThread(cross(cur), boardID, threadID, "Reason")
31}
32
33func main() {
34	path := boardName + "/" + threadID.String()
35	println(boards2.Render(path))
36}
37
38// Output:
39// ⚠ Thread has been flagged as [inappropriate](/r/gnoland/boards2/v0:BoardName/1/flagging-reasons)