z_11_c_filetest.gno
0.89 Kb ยท 36 lines
1package main
2
3// SEND: 1000000ugnot
4
5import (
6 "std"
7 "strconv"
8 "testing"
9
10 "gno.land/r/demo/boards"
11 users "gno.land/r/gnoland/users/v1"
12)
13
14var (
15 bid 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 cross(users.Register)("gnouser123")
22
23 bid = cross(boards.CreateBoard)("test_board")
24 pid = cross(boards.CreateThread)(bid, "First Post in (title)", "Body of the first post. (body)")
25}
26
27func main() {
28 println(boards.Render("test_board/" + strconv.Itoa(int(pid))))
29 // post 2 not exist
30 cross(boards.EditPost)(bid, pid, 2, "Edited: First Post in (title)", "Edited: Body of the first post. (body)")
31 println("----------------------------------------------------")
32 println(boards.Render("test_board/" + strconv.Itoa(int(pid))))
33}
34
35// Error:
36// invalid non-user call