z_1_b_filetest.gno
1.71 Kb · 77 lines
1// Test non default thread 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)
17
18func init() {
19 testing.SetRealm(testing.NewUserRealm("g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh"))
20 boardID = boards2.CreateBoard(cross, "test123", false, false)
21 threadID = boards2.CreateThread(cross, boardID, "Title", "Body")
22
23 // Create another board and repost thread
24 dstBoardID := boards2.CreateBoard(cross, "destination123", false, false)
25 boards2.CreateRepost(cross, boardID, threadID, dstBoardID, "Title", "Body")
26
27 // Edit thread
28 boards2.EditThread(cross, boardID, threadID, "Foo", "Bar")
29
30 // Add a comment to the thread
31 boards2.CreateReply(cross, boardID, threadID, 0, "Comment")
32
33 // Freeze thread
34 boards2.FreezeThread(cross, boardID, threadID)
35
36 // Flag thread
37 boards2.FlagThread(cross, boardID, threadID, "Reason")
38}
39
40func main() {
41 testing.SetRealm(testing.NewCodeRealm("gno.land/r/gnoland/boards2/test"))
42 thread, found := hub.GetThread(uint64(boardID), uint64(threadID))
43 if !found {
44 return
45 }
46
47 println(thread.ID)
48 println(thread.OriginalBoardID) // Only reposts have an original board ID
49 println(thread.OriginalThreadID) // Only reposts have an original thread ID
50 println(thread.BoardID)
51 println(thread.Title)
52 println(thread.Body)
53 println(thread.Hidden)
54 println(thread.Readonly)
55 println(thread.CommentCount)
56 println(thread.RepostCount)
57 println(thread.FlagCount)
58 println(thread.Creator)
59 println(thread.CreatedAt)
60 println(thread.UpdatedAt)
61}
62
63// Output:
64// 1
65// 0
66// 0
67// 1
68// Foo
69// Bar
70// true
71// true
72// 1
73// 1
74// 1
75// g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh
76// 1234567890
77// 1234567890