Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_9_filetest.gno

1.20 Kb · 39 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	firstBoard  boards.BoardID
15	secondBoard boards.BoardID
16	pid         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	firstBoard = boards.CreateBoard(cross, "first_board")
24	secondBoard = boards.CreateBoard(cross, "second_board")
25	pid = boards.CreateThread(cross, firstBoard, "First Post in (title)", "Body of the first post. (body)")
26
27	boards.CreateRepost(cross, firstBoard, pid, "First Post in (title)", "Body of the first post. (body)", secondBoard)
28}
29
30func main() {
31	println(boards.Render("second_board/" + strconv.Itoa(int(pid))))
32}
33
34// Output:
35// # First Post in (title)
36//
37// Body of the first post. (body)
38// \- [@gnouser123](/u/gnouser123), [2009-02-13 11:31pm (UTC)](/r/archive/boards:second_board/1/1) \[[reply](/r/archive/boards$help&func=CreateReply&bid=2&postid=1&threadid=1)] \[[x](/r/archive/boards$help&func=DeletePost&bid=2&postid=1&threadid=1)]
39//