z_10_b_filetest.gno

0.84 Kb ยท 37 lines
 1// PKGPATH: gno.land/r/demo/boards_test
 2package boards_test
 3
 4// SEND: 1000000ugnot
 5
 6import (
 7	"std"
 8	"strconv"
 9	"testing"
10
11	"gno.land/r/demo/boards"
12	users "gno.land/r/gnoland/users/v1"
13)
14
15var (
16	bid boards.BoardID
17	pid boards.PostID
18)
19
20func init() {
21	testing.SetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller
22	users.Register("gnouser123")
23
24	bid = boards.CreateBoard("test_board")
25	pid = boards.CreateThread(bid, "First Post in (title)", "Body of the first post. (body)")
26}
27
28func main() {
29	println(boards.Render("test_board/" + strconv.Itoa(int(pid))))
30	// pid of 2 not exist
31	boards.DeletePost(bid, 2, 2, "")
32	println("----------------------------------------------------")
33	println(boards.Render("test_board/" + strconv.Itoa(int(pid))))
34}
35
36// Error:
37// invalid non-user call