z_12_filetest.gno

1.25 Kb ยท 47 lines
 1// PKGPATH: gno.land/r/demo/boards_test
 2package boards_test
 3
 4// SEND: 1000000ugnot
 5
 6import (
 7	"std"
 8	"testing"
 9
10	"gno.land/r/demo/boards"
11	users "gno.land/r/gnoland/users/v1"
12)
13
14var (
15	bid1 boards.BoardID
16	bid2 boards.BoardID
17	pid  boards.PostID
18)
19
20func init() {
21	testing.SetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller
22	users.Register("gnouser123")
23
24	bid1 = boards.CreateBoard("test_board1")
25	pid = boards.CreateThread(bid1, "First Post (title)", "Body of the first post. (body)")
26	bid2 = boards.CreateBoard("test_board2")
27}
28
29func main() {
30	testing.SetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm")))
31	rid := boards.CreateRepost(bid1, pid, "", "Check this out", bid2)
32	println(rid)
33	println(boards.Render("test_board2"))
34}
35
36// Output:
37// 1
38// \[[post](/r/demo/boards$help&func=CreateThread&bid=2)]
39//
40// ----------------------------------------
41// Repost: Check this out
42// ## [First Post (title)](/r/demo/boards:test_board1/1)
43//
44// Body of the first post. (body)
45// \- [@gnouser123](/u/gnouser123), [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)
46//
47//