z_8_filetest.gno
1.72 Kb ยท 48 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 rid boards.PostID
18)
19
20func init() {
21 testing.SetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller
22 users.Register(cross, "gnouser123")
23
24 bid = boards.CreateBoard(cross, "test_board")
25 boards.CreateThread(cross, bid, "First Post (title)", "Body of the first post. (body)")
26 pid = boards.CreateThread(cross, bid, "Second Post (title)", "Body of the second post. (body)")
27 rid = boards.CreateReply(cross, bid, pid, pid, "Reply of the second post")
28}
29
30func main() {
31 testing.SetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm")))
32 boards.CreateReply(cross, bid, pid, pid, "Second reply of the second post\n")
33 rid2 := boards.CreateReply(cross, bid, pid, rid, "First reply of the first reply\n")
34 println(boards.Render("test_board/" + strconv.Itoa(int(pid)) + "/" + strconv.Itoa(int(rid2))))
35}
36
37// Output:
38// _[see thread](/r/demo/boards:test_board/2)_
39//
40// Reply of the second post
41// \- [@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)]
42//
43// _[see all 1 replies](/r/demo/boards:test_board/2/3)_
44//
45// > First reply of the first reply
46// >
47// > \- [@gnouser123](/u/gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/2/5) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&postid=5&threadid=2)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&postid=5&threadid=2)]
48//