z_hub_8_b_filetest.gno
1.20 Kb · 41 lines
1// PKGPATH: gno.land/r/gnoland/boards2/v1/filetests/z_hub_8_b_filetest
2
3// Test getting replies from a comment
4package z_hub_8_b_filetest
5
6import (
7 "testing"
8
9 boards2 "gno.land/r/gnoland/boards2/v1"
10)
11
12var comment boards2.Comment
13
14func init(cur realm) {
15 testing.SetRealm(testing.NewUserRealm("g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh"))
16 boardID := boards2.CreateBoard(cross(cur), "test123", false, false)
17 threadID := boards2.CreateThread(cross(cur), boardID, "Title", "Body")
18 commentID := boards2.CreateReply(cross(cur), boardID, threadID, 0, "Comment")
19
20 // Create replies
21 boards2.CreateReply(cross(cur), boardID, threadID, commentID, "Reply 1")
22 subCommentID := boards2.CreateReply(cross(cur), boardID, threadID, commentID, "Reply 2")
23
24 // Add a sub-reply (it should not be included in the output)
25 boards2.CreateReply(cross(cur), boardID, threadID, subCommentID, "Reply 3")
26
27 // Get readonly comment
28 comment, _ = boards2.GetComment(uint64(boardID), uint64(threadID), uint64(commentID))
29}
30
31func main(cur realm) {
32 replies := boards2.GetReplies(comment.BoardID(), comment.ThreadID(), comment.ID(), 0, comment.ReplyCount())
33
34 for _, r := range replies {
35 println(r.ID(), r.Body())
36 }
37}
38
39// Output:
40// 3 Reply 1
41// 4 Reply 2