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 pid = boards.CreateThread(bid, "First Post in (title)", "Body of the first post. (body)")
27}
28
29func main() {
30 println(boards.Render("test_board/" + strconv.Itoa(int(pid))))
31 caller := testutils.TestAddress("caller")
32 std.TestSetRealm(std.NewUserRealm(caller))
33 boards.EditPost(bid, pid, pid, "Edited: First Post in (title)", "Edited: Body of the first post. (body)")
34 println("----------------------------------------------------")
35 println(boards.Render("test_board/" + strconv.Itoa(int(pid))))
36}
37
38// Output:
39// # First Post in (title)
40//
41// Body of the first post. (body)
42// \- [@gnouser](/r/demo/users:gnouser), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/1) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&postid=1&threadid=1)] \[[repost](/r/demo/boards$help&func=CreateRepost&bid=1&postid=1)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&postid=1&threadid=1)]
43//
44// ----------------------------------------------------
45// # Edited: First Post in (title)
46//
47// Edited: Body of the first post. (body)
48// \- [@gnouser](/r/demo/users:gnouser), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/1) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&postid=1&threadid=1)] \[[repost](/r/demo/boards$help&func=CreateRepost&bid=1&postid=1)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&postid=1&threadid=1)]
49//
z_11_filetest.gno
1.72 Kb ยท 49 lines