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

1.48 Kb · 66 lines
 1// PKGPATH: gno.land/r/gnoland/boards2/v0/filetests/z_hub_9_b_filetest
 2
 3// Test non default thread comment values
 4package z_hub_9_b_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	commentID boards.ID
18)
19
20func init(cur realm) {
21	testing.SetRealm(testing.NewUserRealm("g1skl80cuz8zq3lul9pgz5pc35l2pfzgxgfpsqkx"))
22	boardID = boards2.CreateBoard(cross(cur), "origin123", false, false)
23	threadID = boards2.CreateThread(cross(cur), boardID, "Title", "Body")
24	commentID = boards2.CreateReply(cross(cur), boardID, threadID, 0, "Comment")
25
26	// Edit comment
27	boards2.EditReply(cross(cur), boardID, threadID, commentID, "Test comment")
28
29	// Create a comment reply
30	boards2.CreateReply(cross(cur), boardID, threadID, commentID, "Reply")
31
32	// Flag comment
33	boards2.FlagReply(cross(cur), boardID, threadID, commentID, "Reason")
34}
35
36func main(cur realm) {
37	comment, found := boards2.GetComment(uint64(boardID), uint64(threadID), uint64(commentID))
38	if !found {
39		return
40	}
41
42	println(comment.ID())
43	println(comment.BoardID())
44	println(comment.ThreadID())
45	println(comment.ParentID())
46	println(comment.Body())
47	println(comment.Hidden())
48	println(comment.ReplyCount())
49	println(comment.FlagCount())
50	println(comment.Creator())
51	println(comment.CreatedAt())
52	println(comment.UpdatedAt())
53}
54
55// Output:
56// 2
57// 1
58// 1
59// 1
60// Test comment
61// true
62// 1
63// 1
64// g1skl80cuz8zq3lul9pgz5pc35l2pfzgxgfpsqkx
65// 1234567890
66// 1234567890