z_12_filetest.gno

1.23 Kb ยท 46 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 (
14	bid1 boards.BoardID
15	bid2 boards.BoardID
16	pid  boards.PostID
17)
18
19func init() {
20	testing.SetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller
21	users.Register(cross, "gnouser123")
22
23	bid1 = boards.CreateBoard(cross, "test_board1")
24	pid = boards.CreateThread(cross, bid1, "First Post (title)", "Body of the first post. (body)")
25	bid2 = boards.CreateBoard(cross, "test_board2")
26}
27
28func main() {
29	testing.SetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm")))
30	rid := boards.CreateRepost(cross, bid1, pid, "", "Check this out", bid2)
31	println(rid)
32	println(boards.Render("test_board2"))
33}
34
35// Output:
36// 1
37// \[[post](/r/demo/boards$help&func=CreateThread&bid=2)]
38//
39// ----------------------------------------
40// Repost: Check this out
41// ## [First Post (title)](/r/demo/boards:test_board1/1)
42//
43// Body of the first post. (body)
44// \- [@gnouser123](/u/gnouser123), [2009-02-13 11:31pm UTC](/r/demo/boards:test_board1/1) \[[x](/r/demo/boards$help&func=DeletePost&bid=1&postid=1&threadid=1)] (0 replies) (1 reposts)
45//
46//