Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_0_filetest.gno

1.47 Kb · 43 lines
 1package main
 2
 3// SEND: 1000000ugnot
 4
 5import (
 6	"testing"
 7
 8	"gno.land/r/archive/boards"
 9	uinit "gno.land/r/sys/users/init"
10)
11
12var bid boards.BoardID
13
14func init() {
15	testing.SetRealm(testing.NewUserRealm(address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller
16	uinit.RegisterUser(cross, "gnouser123", address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))
17
18	bid = boards.CreateBoard(cross, "test_board")
19	boards.CreateThread(cross, bid, "First Post (title)", "Body of the first post. (body)")
20	pid := boards.CreateThread(cross, bid, "Second Post (title)", "Body of the second post. (body)")
21	boards.CreateReply(cross, bid, pid, pid, "Reply of the second post")
22}
23
24func main() {
25	println(boards.Render("test_board"))
26}
27
28// Output:
29// \[[post](/r/archive/boards$help&func=CreateThread&bid=1)]
30//
31// ----------------------------------------
32// ## [First Post (title)](/r/archive/boards:test_board/1)
33//
34// Body of the first post. (body)
35// \- [@gnouser123](/u/gnouser123), [2009-02-13 11:31pm UTC](/r/archive/boards:test_board/1) \[[x](/r/archive/boards$help&func=DeletePost&bid=1&postid=1&threadid=1)] (0 replies) (0 reposts)
36//
37// ----------------------------------------
38// ## [Second Post (title)](/r/archive/boards:test_board/2)
39//
40// Body of the second post. (body)
41// \- [@gnouser123](/u/gnouser123), [2009-02-13 11:31pm UTC](/r/archive/boards:test_board/2) \[[x](/r/archive/boards$help&func=DeletePost&bid=1&postid=2&threadid=2)] (1 replies) (0 reposts)
42//
43//