z_10_a_filetest.gno

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