z_9_a_filetest.gno
1.15 Kb · 57 lines
1// Test 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
26func main() {
27 testing.SetRealm(testing.NewCodeRealm("gno.land/r/gnoland/boards2/test"))
28 comment, found := hub.GetComment(uint64(boardID), uint64(threadID), uint64(commentID))
29 if !found {
30 return
31 }
32
33 println(comment.ID)
34 println(comment.BoardID)
35 println(comment.ThreadID)
36 println(comment.ParentID)
37 println(comment.Body)
38 println(comment.Hidden)
39 println(comment.ReplyCount)
40 println(comment.FlagCount)
41 println(comment.Creator)
42 println(comment.CreatedAt)
43 println(comment.UpdatedAt)
44}
45
46// Output:
47// 2
48// 1
49// 1
50// 1
51// Comment
52// false
53// 0
54// 0
55// g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh
56// 1234567890
57// 0