z_9_filetest.gno

1.14 Kb ยท 40 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	firstBoard  boards.BoardID
16	secondBoard boards.BoardID
17	pid         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	firstBoard = boards.CreateBoard(cross, "first_board")
25	secondBoard = boards.CreateBoard(cross, "second_board")
26	pid = boards.CreateThread(cross, firstBoard, "First Post in (title)", "Body of the first post. (body)")
27
28	boards.CreateRepost(cross, firstBoard, pid, "First Post in (title)", "Body of the first post. (body)", secondBoard)
29}
30
31func main() {
32	println(boards.Render("second_board/" + strconv.Itoa(int(pid))))
33}
34
35// Output:
36// # First Post in (title)
37//
38// Body of the first post. (body)
39// \- [@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)]
40//