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_9_c_filetest.gno

1.00 Kb · 42 lines
 1// PKGPATH: gno.land/r/gnoland/boards2/v0/filetests/z_hub_9_c_filetest
 2
 3// Test getting a nested reply by ID
 4package z_hub_9_c_filetest
 5
 6import (
 7	"testing"
 8
 9	"gno.land/p/gnoland/boards/v0"
10
11	boards2 "gno.land/r/gnoland/boards2/v0"
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("g1skl80cuz8zq3lul9pgz5pc35l2pfzgxgfpsqkx"))
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
26	// Reply to the comment, so the reply is not a top level comment
27	replyID = boards2.CreateReply(cross(cur), boardID, threadID, commentID, "Reply")
28}
29
30func main(cur realm) {
31	reply, found := boards2.GetComment(uint64(boardID), uint64(threadID), uint64(replyID))
32	println(found)
33	println(reply.ID())
34	println(reply.ParentID())
35	println(reply.Body())
36}
37
38// Output:
39// true
40// 3
41// 2
42// Reply