z_10_c_filetest.gno
2.11 Kb · 51 lines
1package main
2
3// SEND: 1000000ugnot
4
5import (
6 "strconv"
7 "testing"
8
9 "gno.land/r/archive/boards"
10 uinit "gno.land/r/sys/users/init"
11)
12
13var (
14 bid boards.BoardID
15 pid boards.PostID
16 rid boards.PostID
17)
18
19func init() {
20 testing.SetRealm(testing.NewUserRealm(address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller
21 uinit.RegisterUser(cross, "gnouser123", address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))
22
23 bid = boards.CreateBoard(cross, "test_board")
24 pid = boards.CreateThread(cross, bid, "First Post in (title)", "Body of the first post. (body)")
25 rid = boards.CreateReply(cross, bid, pid, pid, "First reply of the First post\n")
26}
27
28func main() {
29 println(boards.Render("test_board/" + strconv.Itoa(int(pid))))
30 testing.SetRealm(testing.NewUserRealm(address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm")))
31 boards.DeletePost(cross, bid, pid, rid, "")
32 println("----------------------------------------------------")
33 println(boards.Render("test_board/" + strconv.Itoa(int(pid))))
34}
35
36// Output:
37// # First Post in (title)
38//
39// Body of the first post. (body)
40// \- [@gnouser123](/u/gnouser123), [2009-02-13 11:31pm (UTC)](/r/archive/boards:test_board/1) \[[reply](/r/archive/boards$help&func=CreateReply&bid=1&postid=1&threadid=1)] \[[repost](/r/archive/boards$help&func=CreateRepost&bid=1&postid=1)] \[[x](/r/archive/boards$help&func=DeletePost&bid=1&postid=1&threadid=1)]
41//
42// > First reply of the First post
43// >
44// > \- [@gnouser123](/u/gnouser123), [2009-02-13 11:31pm (UTC)](/r/archive/boards:test_board/1/2) \[[reply](/r/archive/boards$help&func=CreateReply&bid=1&postid=2&threadid=1)] \[[x](/r/archive/boards$help&func=DeletePost&bid=1&postid=2&threadid=1)]
45//
46// ----------------------------------------------------
47// # First Post in (title)
48//
49// Body of the first post. (body)
50// \- [@gnouser123](/u/gnouser123), [2009-02-13 11:31pm (UTC)](/r/archive/boards:test_board/1) \[[reply](/r/archive/boards$help&func=CreateReply&bid=1&postid=1&threadid=1)] \[[repost](/r/archive/boards$help&func=CreateRepost&bid=1&postid=1)] \[[x](/r/archive/boards$help&func=DeletePost&bid=1&postid=1&threadid=1)]
51//