z_11_d_filetest.gno

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