z_0_filetest.gno

1.42 Kb ยท 45 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 bid boards.BoardID
15
16func init() {
17	testing.SetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller
18	users.Register("gnouser123")
19
20	bid = boards.CreateBoard("test_board")
21	boards.CreateThread(bid, "First Post (title)", "Body of the first post. (body)")
22	pid := boards.CreateThread(bid, "Second Post (title)", "Body of the second post. (body)")
23	boards.CreateReply(bid, pid, pid, "Reply of the second post")
24}
25
26func main() {
27	println(boards.Render("test_board"))
28}
29
30// Output:
31// \[[post](/r/demo/boards$help&func=CreateThread&bid=1)]
32//
33// ----------------------------------------
34// ## [First Post (title)](/r/demo/boards:test_board/1)
35//
36// Body of the first post. (body)
37// \- [@gnouser123](/u/gnouser123), [2009-02-13 11:31pm UTC](/r/demo/boards:test_board/1) \[[x](/r/demo/boards$help&func=DeletePost&bid=1&postid=1&threadid=1)] (0 replies) (0 reposts)
38//
39// ----------------------------------------
40// ## [Second Post (title)](/r/demo/boards:test_board/2)
41//
42// Body of the second post. (body)
43// \- [@gnouser123](/u/gnouser123), [2009-02-13 11:31pm UTC](/r/demo/boards:test_board/2) \[[x](/r/demo/boards$help&func=DeletePost&bid=1&postid=2&threadid=2)] (1 replies) (0 reposts)
44//
45//