z_11_d_filetest.gno

2.35 Kb ยท 56 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	pid = boards.CreateThread(cross, bid, "First Post in (title)", "Body of the first post. (body)")
26	rid = boards.CreateReply(cross, bid, pid, pid, "First reply of the First post\n")
27}
28
29func main() {
30	println(boards.Render("test_board/" + strconv.Itoa(int(pid))))
31	testing.SetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm")))
32	boards.EditPost(cross, bid, pid, rid, "", "Edited: First reply of the First post\n")
33	println("----------------------------------------------------")
34	println(boards.Render("test_board/" + strconv.Itoa(int(pid))))
35}
36
37// Output:
38// # First Post in (title)
39//
40// Body of the first post. (body)
41// \- [@gnouser123](/u/gnouser123), [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)]
42//
43// > First reply of the First post
44// >
45// > \- [@gnouser123](/u/gnouser123), [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)]
46//
47// ----------------------------------------------------
48// # First Post in (title)
49//
50// Body of the first post. (body)
51// \- [@gnouser123](/u/gnouser123), [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)]
52//
53// > Edited: First reply of the First post
54// >
55// > \- [@gnouser123](/u/gnouser123), [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)]
56//