Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_11_b_filetest.gno

0.94 Kb · 35 lines
 1package main
 2
 3// SEND: 1000000ugnot
 4
 5import (
 6	"strconv"
 7	"testing"
 8
 9	"gno.land/r/archive/boards"
10	uinit "gno.land/r/sys/users/init"
11)
12
13var (
14	bid 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	bid = boards.CreateBoard(cross, "test_board")
23	pid = boards.CreateThread(cross, 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	// thread 2 not exist
29	boards.EditPost(cross, bid, 2, pid, "Edited: First Post in (title)", "Edited: Body of the first post. (body)")
30	println("----------------------------------------------------")
31	println(boards.Render("test_board/" + strconv.Itoa(int(pid))))
32}
33
34// Error:
35// invalid non-user call