Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_5_b_filetest.gno

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