z_hub_8_c_filetest.gno
1.11 Kb · 42 lines
1// PKGPATH: gno.land/r/gnoland/boards2/v1/filetests/z_hub_8_c_filetest
2
3// Test getting replies from a nested reply
4package z_hub_8_c_filetest
5
6import (
7 "testing"
8
9 "gno.land/p/gnoland/boards"
10
11 boards2 "gno.land/r/gnoland/boards2/v1"
12)
13
14var (
15 boardID boards.ID
16 threadID boards.ID
17 replyID boards.ID
18)
19
20func init(cur realm) {
21 testing.SetRealm(testing.NewUserRealm("g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh"))
22 boardID = boards2.CreateBoard(cross(cur), "test123", false, false)
23 threadID = boards2.CreateThread(cross(cur), boardID, "Title", "Body")
24 commentID := boards2.CreateReply(cross(cur), boardID, threadID, 0, "Comment")
25 replyID = boards2.CreateReply(cross(cur), boardID, threadID, commentID, "Reply")
26
27 // Create sub-replies of the nested reply
28 boards2.CreateReply(cross(cur), boardID, threadID, replyID, "Sub-reply 1")
29 boards2.CreateReply(cross(cur), boardID, threadID, replyID, "Sub-reply 2")
30}
31
32func main(cur realm) {
33 replies := boards2.GetReplies(uint64(boardID), uint64(threadID), uint64(replyID), 0, 10)
34
35 for _, r := range replies {
36 println(r.ID(), r.Body())
37 }
38}
39
40// Output:
41// 4 Sub-reply 1
42// 5 Sub-reply 2