z_0_filetest.gno
1.40 Kb ยท 44 lines
1package main
2
3// SEND: 1000000ugnot
4
5import (
6 "std"
7 "testing"
8
9 "gno.land/r/demo/boards"
10 users "gno.land/r/gnoland/users/v1"
11)
12
13var bid boards.BoardID
14
15func init() {
16 testing.SetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller
17 users.Register(cross, "gnouser123")
18
19 bid = boards.CreateBoard(cross, "test_board")
20 boards.CreateThread(cross, bid, "First Post (title)", "Body of the first post. (body)")
21 pid := boards.CreateThread(cross, bid, "Second Post (title)", "Body of the second post. (body)")
22 boards.CreateReply(cross, bid, pid, pid, "Reply of the second post")
23}
24
25func main() {
26 println(boards.Render("test_board"))
27}
28
29// Output:
30// \[[post](/r/demo/boards$help&func=CreateThread&bid=1)]
31//
32// ----------------------------------------
33// ## [First Post (title)](/r/demo/boards:test_board/1)
34//
35// Body of the first post. (body)
36// \- [@gnouser123](/u/gnouser123), [2009-02-13 11:31pm UTC](/r/demo/boards:test_board/1) \[[x](/r/demo/boards$help&func=DeletePost&bid=1&postid=1&threadid=1)] (0 replies) (0 reposts)
37//
38// ----------------------------------------
39// ## [Second Post (title)](/r/demo/boards:test_board/2)
40//
41// Body of the second post. (body)
42// \- [@gnouser123](/u/gnouser123), [2009-02-13 11:31pm UTC](/r/demo/boards:test_board/2) \[[x](/r/demo/boards$help&func=DeletePost&bid=1&postid=2&threadid=2)] (1 replies) (0 reposts)
43//
44//