z_12_filetest.gno
1.29 Kb · 45 lines
1package main
2
3// SEND: 1000000ugnot
4
5import (
6 "testing"
7
8 "gno.land/r/archive/boards"
9 uinit "gno.land/r/sys/users/init"
10)
11
12var (
13 bid1 boards.BoardID
14 bid2 boards.BoardID
15 pid boards.PostID
16)
17
18func init() {
19 testing.SetRealm(testing.NewUserRealm(address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller
20 uinit.RegisterUser(cross, "gnouser123", address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))
21
22 bid1 = boards.CreateBoard(cross, "test_board1")
23 pid = boards.CreateThread(cross, bid1, "First Post (title)", "Body of the first post. (body)")
24 bid2 = boards.CreateBoard(cross, "test_board2")
25}
26
27func main() {
28 testing.SetRealm(testing.NewUserRealm(address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm")))
29 rid := boards.CreateRepost(cross, bid1, pid, "", "Check this out", bid2)
30 println(rid)
31 println(boards.Render("test_board2"))
32}
33
34// Output:
35// 1
36// \[[post](/r/archive/boards$help&func=CreateThread&bid=2)]
37//
38// ----------------------------------------
39// Repost: Check this out
40// ## [First Post (title)](/r/archive/boards:test_board1/1)
41//
42// Body of the first post. (body)
43// \- [@gnouser123](/u/gnouser123), [2009-02-13 11:31pm UTC](/r/archive/boards:test_board1/1) \[[x](/r/archive/boards$help&func=DeletePost&bid=1&postid=1&threadid=1)] (0 replies) (1 reposts)
44//
45//