Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_1_b_filetest.gno

1.63 Kb · 75 lines
 1// Test non default thread values
 2package main
 3
 4import (
 5	"testing"
 6
 7	"gno.land/p/gnoland/boards"
 8
 9	boards2 "gno.land/r/gnoland/boards2/v1"
10	"gno.land/r/gnoland/boards2/v1/hub"
11)
12
13var (
14	boardID  boards.ID
15	threadID boards.ID
16)
17
18func init() {
19	testing.SetRealm(testing.NewUserRealm("g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh"))
20	boardID = boards2.CreateBoard(cross, "test123", false, false)
21	threadID = boards2.CreateThread(cross, boardID, "Title", "Body")
22
23	// Create another board and repost thread
24	dstBoardID := boards2.CreateBoard(cross, "destination123", false, false)
25	boards2.CreateRepost(cross, boardID, threadID, dstBoardID, "Title", "Body")
26
27	// Edit thread
28	boards2.EditThread(cross, boardID, threadID, "Foo", "Bar")
29
30	// Add a comment to the thread
31	boards2.CreateReply(cross, boardID, threadID, 0, "Comment")
32
33	// Freeze thread
34	boards2.FreezeThread(cross, boardID, threadID)
35
36	// Flag thread
37	boards2.FlagThread(cross, boardID, threadID, "Reason")
38}
39
40func main() {
41	testing.SetRealm(testing.NewCodeRealm("gno.land/r/gnoland/boards2/test"))
42	thread, found := hub.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.BoardID)
50	println(thread.Title)
51	println(thread.Body)
52	println(thread.Hidden)
53	println(thread.Readonly)
54	println(thread.CommentCount)
55	println(thread.RepostCount)
56	println(thread.FlagCount)
57	println(thread.Creator)
58	println(thread.CreatedAt)
59	println(thread.UpdatedAt)
60}
61
62// Output:
63// 1
64// 0
65// 1
66// Foo
67// Bar
68// true
69// true
70// 1
71// 1
72// 1
73// g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh
74// 1234567890
75// 1234567890