z_11_d_filetest.gno
2.36 Kb ยท 57 lines
1// PKGPATH: gno.land/r/demo/boards_test
2package boards_test
3
4// SEND: 1000000ugnot
5
6import (
7 "std"
8 "strconv"
9 "testing"
10
11 "gno.land/r/demo/boards"
12 users "gno.land/r/gnoland/users/v1"
13)
14
15var (
16 bid boards.BoardID
17 pid boards.PostID
18 rid boards.PostID
19)
20
21func init() {
22 testing.SetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller
23 users.Register("gnouser123")
24
25 bid = boards.CreateBoard("test_board")
26 pid = boards.CreateThread(bid, "First Post in (title)", "Body of the first post. (body)")
27 rid = boards.CreateReply(bid, pid, pid, "First reply of the First post\n")
28}
29
30func main() {
31 println(boards.Render("test_board/" + strconv.Itoa(int(pid))))
32 testing.SetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm")))
33 boards.EditPost(bid, pid, rid, "", "Edited: First reply of the First post\n")
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// \- [@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)]
43//
44// > First reply of the First post
45// >
46// > \- [@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)]
47//
48// ----------------------------------------------------
49// # First Post in (title)
50//
51// Body of the first post. (body)
52// \- [@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)]
53//
54// > Edited: First reply of the First post
55// >
56// > \- [@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)]
57//