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

1.88 Kb · 80 lines
 1// PKGPATH: gno.land/r/gnoland/boards2/v0/filetests/z_hub_1_c_filetest
 2
 3// Test non default reposted thread values
 4package z_hub_1_c_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	srcBoardID := boards2.CreateBoard(cross(cur), "origin123", false, false)
22
23	// Create two threads where the second is the one to repost
24	boards2.CreateThread(cross(cur), srcBoardID, "Title1", "Body1")
25	srcThreadID := boards2.CreateThread(cross(cur), srcBoardID, "Title2", "Body2") // ID = 2
26
27	// Create repost
28	boardID = boards2.CreateBoard(cross(cur), "test123", false, false)
29	threadID = boards2.CreateRepost(cross(cur), srcBoardID, srcThreadID, boardID, "Title", "Body")
30
31	// Edit repost
32	boards2.EditThread(cross(cur), boardID, threadID, "Foo", "Bar")
33
34	// Add a comment to the repost
35	boards2.CreateReply(cross(cur), boardID, threadID, 0, "Comment")
36
37	// Freeze repost
38	boards2.FreezeThread(cross(cur), boardID, threadID)
39
40	// Flag repost
41	boards2.FlagThread(cross(cur), boardID, threadID, "Reason")
42}
43
44func main(cur realm) {
45	thread, found := boards2.GetThread(uint64(boardID), uint64(threadID))
46	if !found {
47		return
48	}
49
50	println(thread.ID())
51	println(thread.OriginalBoardID())
52	println(thread.OriginalThreadID())
53	println(thread.BoardID())
54	println(thread.Title())
55	println(thread.Body())
56	println(thread.Hidden())
57	println(thread.Readonly())
58	println(thread.CommentCount())
59	println(thread.RepostCount()) // Reposts can't be reposted, so count must be 0
60	println(thread.FlagCount())
61	println(thread.Creator())
62	println(thread.CreatedAt())
63	println(thread.UpdatedAt())
64}
65
66// Output:
67// 1
68// 1
69// 2
70// 2
71// Foo
72// Bar
73// true
74// true
75// 1
76// 0
77// 1
78// g1skl80cuz8zq3lul9pgz5pc35l2pfzgxgfpsqkx
79// 1234567890
80// 1234567890