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)
19
20func init() {
21 caller := testutils.TestAddress("caller")
22 std.TestSetRealm(std.NewUserRealm(caller))
23 users.Register("", "gnouser", "my profile")
24
25 bid = boards.CreateBoard("test_board")
26 boards.CreateThread(bid, "First Post (title)", "Body of the first post. (body)")
27 pid = boards.CreateThread(bid, "Second Post (title)", "Body of the second post. (body)")
28}
29
30func main() {
31 caller := testutils.TestAddress("caller")
32 std.TestSetRealm(std.NewUserRealm(caller))
33 rid := boards.CreateReply(bid, pid, pid, "Reply of the second post")
34 println(rid)
35 println(boards.Render("test_board/" + strconv.Itoa(int(pid))))
36}
37
38// Output:
39// 3
40// # Second Post (title)
41//
42// Body of the second post. (body)
43// \- [@gnouser](/r/demo/users:gnouser), [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)]
44//
45// > Reply of the second post
46// > \- [@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)]
47//
z_3_filetest.gno
1.49 Kb ยท 47 lines