Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_5_filetest.gno

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