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

1.78 Kb · 77 lines
 1// PKGPATH: gno.land/r/gnoland/boards2/v0/filetests/z_hub_1_b_filetest
 2
 3// Test non default thread values
 4package z_hub_1_b_filetest
 5
 6import (
 7	"testing"
 8
 9	"gno.land/p/gnoland/boards/v0"
10
11	boards2 "gno.land/r/gnoland/boards2/v0"
12)
13
14var (
15	boardID  boards.ID
16	threadID boards.ID
17)
18
19func init(cur realm) {
20	testing.SetRealm(testing.NewUserRealm("g1skl80cuz8zq3lul9pgz5pc35l2pfzgxgfpsqkx"))
21	boardID = boards2.CreateBoard(cross(cur), "test123", false, false)
22	threadID = boards2.CreateThread(cross(cur), boardID, "Title", "Body")
23
24	// Create another board and repost thread
25	dstBoardID := boards2.CreateBoard(cross(cur), "destination123", false, false)
26	boards2.CreateRepost(cross(cur), boardID, threadID, dstBoardID, "Title", "Body")
27
28	// Edit thread
29	boards2.EditThread(cross(cur), boardID, threadID, "Foo", "Bar")
30
31	// Add a comment to the thread
32	boards2.CreateReply(cross(cur), boardID, threadID, 0, "Comment")
33
34	// Freeze thread
35	boards2.FreezeThread(cross(cur), boardID, threadID)
36
37	// Flag thread
38	boards2.FlagThread(cross(cur), boardID, threadID, "Reason")
39}
40
41func main(cur realm) {
42	thread, found := boards2.GetThread(uint64(boardID), uint64(threadID))
43	if !found {
44		return
45	}
46
47	println(thread.ID())
48	println(thread.OriginalBoardID())  // Only reposts have an original board ID
49	println(thread.OriginalThreadID()) // Only reposts have an original thread ID
50	println(thread.BoardID())
51	println(thread.Title())
52	println(thread.Body())
53	println(thread.Hidden())
54	println(thread.Readonly())
55	println(thread.CommentCount())
56	println(thread.RepostCount())
57	println(thread.FlagCount())
58	println(thread.Creator())
59	println(thread.CreatedAt())
60	println(thread.UpdatedAt())
61}
62
63// Output:
64// 1
65// 0
66// 0
67// 1
68// Foo
69// Bar
70// true
71// true
72// 1
73// 1
74// 1
75// g1skl80cuz8zq3lul9pgz5pc35l2pfzgxgfpsqkx
76// 1234567890
77// 1234567890