Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_3_f_filetest.gno

1.13 Kb ยท 47 lines
 1package main
 2
 3// SEND: 1000000ugnot
 4
 5import (
 6	"testing"
 7
 8	"gno.land/p/gnoland/boards"
 9
10	boards2 "gno.land/r/gnoland/boards2/v1"
11	"gno.land/r/gnoland/boards2/v1/permissions"
12	users "gno.land/r/gnoland/users/v1"
13)
14
15const (
16	owner   address = "g16jpf0puufcpcjkph5nxueec8etpcldz7zwgydq" // @devx
17	member  address = "g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj" // @test2
18	name            = "foo123"
19	newName         = "barbaz123"
20)
21
22var bid boards.ID // Operate on board DAO
23
24func init() {
25	testing.SetRealm(testing.NewUserRealm(owner))
26
27	bid = boards2.CreateBoard(cross, name, false, false)
28	boards2.InviteMember(cross, bid, member, permissions.RoleOwner)
29
30	// Test1 is the boards owner and its address has a user already registered
31	// so a new member must register a user with the new board name.
32	testing.SetRealm(testing.NewUserRealm(member))
33	users.Register(cross, newName)
34}
35
36func main() {
37	testing.SetRealm(testing.NewUserRealm(member))
38
39	boards2.RenameBoard(cross, name, newName)
40
41	// Ensure board is renamed by another board owner
42	bid2, _ := boards2.GetBoardIDFromName(cross, newName)
43	println("IDs match =", bid == bid2)
44}
45
46// Output:
47// IDs match = true