Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

z_hub_8_b_filetest.gno

1.20 Kb · 41 lines
 1// PKGPATH: gno.land/r/gnoland/boards2/v0/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/v0"
10)
11
12var comment boards2.Comment
13
14func init(cur realm) {
15	testing.SetRealm(testing.NewUserRealm("g1skl80cuz8zq3lul9pgz5pc35l2pfzgxgfpsqkx"))
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