Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_9_b_filetest.gno

1.57 Kb · 68 lines
 1// PKGPATH: gno.land/r/gnoland/boards2/v1/hub/filetests/z_9_b_filetest
 2
 3// Test non default thread comment values
 4package z_9_b_filetest
 5
 6import (
 7	"testing"
 8
 9	"gno.land/p/gnoland/boards"
10
11	boards2 "gno.land/r/gnoland/boards2/v1"
12	"gno.land/r/gnoland/boards2/v1/hub"
13)
14
15var (
16	boardID   boards.ID
17	threadID  boards.ID
18	commentID boards.ID
19)
20
21func init(cur realm) {
22	testing.SetRealm(testing.NewUserRealm("g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh"))
23	boardID = boards2.CreateBoard(cross(cur), "origin123", false, false)
24	threadID = boards2.CreateThread(cross(cur), boardID, "Title", "Body")
25	commentID = boards2.CreateReply(cross(cur), boardID, threadID, 0, "Comment")
26
27	// Edit comment
28	boards2.EditReply(cross(cur), boardID, threadID, commentID, "Test comment")
29
30	// Create a comment reply
31	boards2.CreateReply(cross(cur), boardID, threadID, commentID, "Reply")
32
33	// Flag comment
34	boards2.FlagReply(cross(cur), boardID, threadID, commentID, "Reason")
35}
36
37func main(cur realm) {
38	testing.SetRealm(testing.NewCodeRealm("gno.land/r/gnoland/boards2/test"))
39	comment, found := hub.GetComment(cross(cur), uint64(boardID), uint64(threadID), uint64(commentID))
40	if !found {
41		return
42	}
43
44	println(comment.ID)
45	println(comment.BoardID)
46	println(comment.ThreadID)
47	println(comment.ParentID)
48	println(comment.Body)
49	println(comment.Hidden)
50	println(comment.ReplyCount)
51	println(comment.FlagCount)
52	println(comment.Creator)
53	println(comment.CreatedAt)
54	println(comment.UpdatedAt)
55}
56
57// Output:
58// 2
59// 1
60// 1
61// 1
62// Test comment
63// true
64// 1
65// 1
66// g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh
67// 1234567890
68// 1234567890