Search Apps Documentation Source Content File Folder Download Copy Actions Download 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/v1/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/v1"
10)
11
12var thread boards2.Thread
13
14func init(cur realm) {
15	testing.SetRealm(testing.NewUserRealm("g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh"))
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