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

1.11 Kb · 41 lines
 1// PKGPATH: gno.land/r/gnoland/boards2/v0/filetests/z_hub_5_b_filetest
 2
 3// Test getting reposts of a thread
 4package z_hub_5_b_filetest
 5
 6import (
 7	"testing"
 8
 9	boards2 "gno.land/r/gnoland/boards2/v0"
10)
11
12var thread boards2.Thread
13
14func init(cur realm) {
15	testing.SetRealm(testing.NewUserRealm("g1skl80cuz8zq3lul9pgz5pc35l2pfzgxgfpsqkx"))
16	boardID := boards2.CreateBoard(cross(cur), "aaa123", false, false)
17	threadID := boards2.CreateThread(cross(cur), boardID, "Title", "Body")
18
19	// Create first repost
20	dstBoardID := boards2.CreateBoard(cross(cur), "bbb123", false, false)
21	boards2.CreateRepost(cross(cur), boardID, threadID, dstBoardID, "First", "Body")
22
23	// Create second repost
24	dstBoardID = boards2.CreateBoard(cross(cur), "ccc123", false, false)
25	boards2.CreateRepost(cross(cur), boardID, threadID, dstBoardID, "Second", "Body")
26
27	// Get readonly thread
28	thread, _ = boards2.GetThread(uint64(boardID), uint64(threadID))
29}
30
31func main(cur realm) {
32	reposts := boards2.GetReposts(thread.BoardID(), thread.ID(), 0, thread.RepostCount())
33
34	for _, t := range reposts {
35		println(t.ID(), t.Title())
36	}
37}
38
39// Output:
40// 1 First
41// 1 Second