z_5_filetest.gno

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