z_5_c_filetest.gno

1.62 Kb ยท 42 lines
 1package main
 2
 3// SEND: 1000000ugnot
 4
 5import (
 6	"std"
 7	"strconv"
 8	"testing"
 9
10	"gno.land/p/demo/testutils"
11	"gno.land/r/demo/boards"
12	users "gno.land/r/gnoland/users/v1"
13)
14
15const admin = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj")
16
17func main() {
18	testing.SetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller
19	users.Register("gnouser123")
20	// create board via registered user
21	bid := boards.CreateBoard("test_board")
22
23	// create post via anon user
24	test2 := testutils.TestAddress("test2")
25	testing.SetOriginCaller(test2)
26	testing.SetOriginSend(std.Coins{{"ugnot", 101000000}})
27
28	pid := boards.CreateThread(bid, "First Post (title)", "Body of the first post. (body)")
29	boards.CreateReply(bid, pid, pid, "Reply of the first post")
30
31	println(boards.Render("test_board/" + strconv.Itoa(int(pid))))
32}
33
34// Output:
35// # First Post (title)
36//
37// Body of the first post. (body)
38// \- [g1w3jhxapjta047h6lta047h6lta047h6laqcyu4](/u/g1w3jhxapjta047h6lta047h6lta047h6laqcyu4), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/1) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&postid=1&threadid=1)] \[[repost](/r/demo/boards$help&func=CreateRepost&bid=1&postid=1)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&postid=1&threadid=1)]
39//
40// > Reply of the first post
41// > \- [g1w3jhxapjta047h6lta047h6lta047h6laqcyu4](/u/g1w3jhxapjta047h6lta047h6lta047h6laqcyu4), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/1/2) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&postid=2&threadid=1)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&postid=2&threadid=1)]
42//