Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_5_b_filetest.gno

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