Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_1_c_filetest.gno

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