z_9_filetest.gno
1.15 Kb ยท 41 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 firstBoard boards.BoardID
17 secondBoard boards.BoardID
18 pid 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 firstBoard = boards.CreateBoard("first_board")
26 secondBoard = boards.CreateBoard("second_board")
27 pid = boards.CreateThread(firstBoard, "First Post in (title)", "Body of the first post. (body)")
28
29 boards.CreateRepost(firstBoard, pid, "First Post in (title)", "Body of the first post. (body)", secondBoard)
30}
31
32func main() {
33 println(boards.Render("second_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/demo/boards:second_board/1/1) \[[reply](/r/demo/boards$help&func=CreateReply&bid=2&postid=1&threadid=1)] \[[x](/r/demo/boards$help&func=DeletePost&bid=2&postid=1&threadid=1)]
41//