z_7_filetest.gno

0.96 Kb ยท 37 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
14func init() {
15	// register
16	testing.SetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller
17	users.Register("gnouser123")
18
19	// create board and post
20	bid := boards.CreateBoard("test_board")
21	boards.CreateThread(bid, "First Post (title)", "Body of the first post. (body)")
22}
23
24func main() {
25	println(boards.Render("test_board"))
26}
27
28// Output:
29// \[[post](/r/demo/boards$help&func=CreateThread&bid=1)]
30//
31// ----------------------------------------
32// ## [First Post (title)](/r/demo/boards:test_board/1)
33//
34// Body of the first post. (body)
35// \- [@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)
36//
37//