z_12_filetest.gno

1.21 Kb ยท 49 lines
 1// PKGPATH: gno.land/r/demo/boards_test
 2package boards_test
 3
 4// SEND: 200000000ugnot
 5
 6import (
 7	"std"
 8
 9	"gno.land/p/demo/testutils"
10	"gno.land/r/demo/boards"
11	"gno.land/r/demo/users"
12)
13
14var (
15	bid1 boards.BoardID
16	bid2 boards.BoardID
17	pid  boards.PostID
18)
19
20func init() {
21	caller := testutils.TestAddress("caller")
22	std.TestSetRealm(std.NewUserRealm(caller))
23	users.Register("", "gnouser", "my profile")
24
25	bid1 = boards.CreateBoard("test_board1")
26	pid = boards.CreateThread(bid1, "First Post (title)", "Body of the first post. (body)")
27	bid2 = boards.CreateBoard("test_board2")
28}
29
30func main() {
31	caller := testutils.TestAddress("caller")
32	std.TestSetRealm(std.NewUserRealm(caller))
33	rid := boards.CreateRepost(bid1, pid, "", "Check this out", bid2)
34	println(rid)
35	println(boards.Render("test_board2"))
36}
37
38// Output:
39// 1
40// \[[post](/r/demo/boards$help&func=CreateThread&bid=2)]
41//
42// ----------------------------------------
43// Repost: Check this out
44// ## [First Post (title)](/r/demo/boards:test_board1/1)
45//
46// Body of the first post. (body)
47// \- [@gnouser](/r/demo/users:gnouser), [2009-02-13 11:31pm UTC](/r/demo/boards:test_board1/1) \[[x](/r/demo/boards$help&func=DeletePost&bid=1&postid=1&threadid=1)] (0 replies) (1 reposts)
48//
49//