1// PKGPATH: gno.land/r/demo/boards_test
2package boards_test
3
4// SEND: 200000000ugnot
5
6import (
7 "std"
8 "strconv"
9
10 "gno.land/p/demo/testutils"
11 "gno.land/r/demo/boards"
12 "gno.land/r/demo/users"
13)
14
15var (
16 bid boards.BoardID
17 pid boards.PostID
18 rid boards.PostID
19)
20
21func init() {
22 caller := testutils.TestAddress("caller")
23 std.TestSetRealm(std.NewUserRealm(caller))
24 users.Register("", "gnouser", "my profile")
25
26 bid = boards.CreateBoard("test_board")
27 boards.CreateThread(bid, "First Post (title)", "Body of the first post. (body)")
28 pid = boards.CreateThread(bid, "Second Post (title)", "Body of the second post. (body)")
29 rid = boards.CreateReply(bid, pid, pid, "Reply of the second post")
30}
31
32func main() {
33 caller := testutils.TestAddress("caller")
34 std.TestSetRealm(std.NewUserRealm(caller))
35 boards.CreateReply(bid, pid, pid, "Second reply of the second post\n")
36 rid2 := boards.CreateReply(bid, pid, rid, "First reply of the first reply\n")
37 println(boards.Render("test_board/" + strconv.Itoa(int(pid)) + "/" + strconv.Itoa(int(rid2))))
38}
39
40// Output:
41// _[see thread](/r/demo/boards:test_board/2)_
42//
43// Reply of the second post
44// \- [@gnouser](/r/demo/users:gnouser), [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)]
45//
46// _[see all 1 replies](/r/demo/boards:test_board/2/3)_
47//
48// > First reply of the first reply
49// >
50// > \- [@gnouser](/r/demo/users:gnouser), [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)]
51//
z_8_filetest.gno
1.69 Kb ยท 51 lines