z_9_filetest.gno

1.13 Kb ยท 42 lines
 1// PKGPATH: gno.land/r/demo/boards_test
 2package boards_test
 3
 4// SEND: 200000000ugnot
 5
 6import (
 7	"std"
 8	"strconv"
 9
10	"gno.land/p/demo/testutils"
11	"gno.land/r/demo/boards"
12	"gno.land/r/demo/users"
13)
14
15var (
16	firstBoard  boards.BoardID
17	secondBoard boards.BoardID
18	pid         boards.PostID
19)
20
21func init() {
22	caller := testutils.TestAddress("caller")
23	std.TestSetRealm(std.NewUserRealm(caller))
24	users.Register("", "gnouser", "my profile")
25
26	firstBoard = boards.CreateBoard("first_board")
27	secondBoard = boards.CreateBoard("second_board")
28	pid = boards.CreateThread(firstBoard, "First Post in (title)", "Body of the first post. (body)")
29
30	boards.CreateRepost(firstBoard, pid, "First Post in (title)", "Body of the first post. (body)", secondBoard)
31}
32
33func main() {
34	println(boards.Render("second_board/" + strconv.Itoa(int(pid))))
35}
36
37// Output:
38// # First Post in (title)
39//
40// Body of the first post. (body)
41// \- [@gnouser](/r/demo/users:gnouser), [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)]
42//