z_1_c_filetest.gno
1.96 Kb · 82 lines
1// PKGPATH: gno.land/r/gnoland/boards2/v1/hub/filetests/z_1_c_filetest
2
3// Test non default reposted thread values
4package z_1_c_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)
19
20func init(cur realm) {
21 testing.SetRealm(testing.NewUserRealm("g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh"))
22 srcBoardID := boards2.CreateBoard(cross(cur), "origin123", false, false)
23
24 // Create two threads where the second is the one to repost
25 boards2.CreateThread(cross(cur), srcBoardID, "Title1", "Body1")
26 srcThreadID := boards2.CreateThread(cross(cur), srcBoardID, "Title2", "Body2") // ID = 2
27
28 // Create repost
29 boardID = boards2.CreateBoard(cross(cur), "test123", false, false)
30 threadID = boards2.CreateRepost(cross(cur), srcBoardID, srcThreadID, boardID, "Title", "Body")
31
32 // Edit repost
33 boards2.EditThread(cross(cur), boardID, threadID, "Foo", "Bar")
34
35 // Add a comment to the repost
36 boards2.CreateReply(cross(cur), boardID, threadID, 0, "Comment")
37
38 // Freeze repost
39 boards2.FreezeThread(cross(cur), boardID, threadID)
40
41 // Flag repost
42 boards2.FlagThread(cross(cur), boardID, threadID, "Reason")
43}
44
45func main(cur realm) {
46 testing.SetRealm(testing.NewCodeRealm("gno.land/r/gnoland/boards2/test"))
47 thread, found := hub.GetThread(cross(cur), uint64(boardID), uint64(threadID))
48 if !found {
49 return
50 }
51
52 println(thread.ID)
53 println(thread.OriginalBoardID)
54 println(thread.OriginalThreadID)
55 println(thread.BoardID)
56 println(thread.Title)
57 println(thread.Body)
58 println(thread.Hidden)
59 println(thread.Readonly)
60 println(thread.CommentCount)
61 println(thread.RepostCount) // Reposts can't be reposted, so count must be 0
62 println(thread.FlagCount)
63 println(thread.Creator)
64 println(thread.CreatedAt)
65 println(thread.UpdatedAt)
66}
67
68// Output:
69// 1
70// 1
71// 2
72// 2
73// Foo
74// Bar
75// true
76// true
77// 1
78// 0
79// 1
80// g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh
81// 1234567890
82// 1234567890