Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_1_b_filetest.gno

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