Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_9_b_filetest.gno

1.43 Kb · 66 lines
 1// Test non default thread comment values
 2package main
 3
 4import (
 5	"testing"
 6
 7	"gno.land/p/gnoland/boards"
 8
 9	boards2 "gno.land/r/gnoland/boards2/v1"
10	"gno.land/r/gnoland/boards2/v1/hub"
11)
12
13var (
14	boardID   boards.ID
15	threadID  boards.ID
16	commentID boards.ID
17)
18
19func init() {
20	testing.SetRealm(testing.NewUserRealm("g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh"))
21	boardID = boards2.CreateBoard(cross, "origin123", false, false)
22	threadID = boards2.CreateThread(cross, boardID, "Title", "Body")
23	commentID = boards2.CreateReply(cross, boardID, threadID, 0, "Comment")
24
25	// Edit comment
26	boards2.EditReply(cross, boardID, threadID, commentID, "Test comment")
27
28	// Create a comment reply
29	boards2.CreateReply(cross, boardID, threadID, commentID, "Reply")
30
31	// Flag comment
32	boards2.FlagReply(cross, boardID, threadID, commentID, "Reason")
33}
34
35func main() {
36	testing.SetRealm(testing.NewCodeRealm("gno.land/r/gnoland/boards2/test"))
37	comment, found := hub.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// g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh
65// 1234567890
66// 1234567890