Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_8_filetest.gno

1.79 Kb · 47 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	rid boards.PostID
17)
18
19func init() {
20	testing.SetRealm(testing.NewUserRealm(address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller
21	uinit.RegisterUser(cross, "gnouser123", address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))
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	rid = boards.CreateReply(cross, bid, pid, pid, "Reply of the second post")
27}
28
29func main() {
30	testing.SetRealm(testing.NewUserRealm(address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm")))
31	boards.CreateReply(cross, bid, pid, pid, "Second reply of the second post\n")
32	rid2 := boards.CreateReply(cross, bid, pid, rid, "First reply of the first reply\n")
33	println(boards.Render("test_board/" + strconv.Itoa(int(pid)) + "/" + strconv.Itoa(int(rid2))))
34}
35
36// Output:
37// _[see thread](/r/archive/boards:test_board/2)_
38//
39// Reply of the second post
40// \- [@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)]
41//
42// _[see all 1 replies](/r/archive/boards:test_board/2/3)_
43//
44// > First reply of the first reply
45// >
46// > \- [@gnouser123](/u/gnouser123), [2009-02-13 11:31pm (UTC)](/r/archive/boards:test_board/2/5) \[[reply](/r/archive/boards$help&func=CreateReply&bid=1&postid=5&threadid=2)] \[[x](/r/archive/boards$help&func=DeletePost&bid=1&postid=5&threadid=2)]
47//