Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_rename_board_06_filetest.gno

1.14 Kb · 44 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	uinit "gno.land/r/sys/users/init"
12)
13
14const (
15	owner   address = "g16jpf0puufcpcjkph5nxueec8etpcldz7zwgydq"
16	member  address = "g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj" // @test2
17	member2 address = "g1vh7krmmzfua5xjmkatvmx09z37w34lsvd2mxa5"
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	bid = boards2.CreateBoard(cross, name, false, false)
27	boards2.InviteMember(cross, bid, member, boards2.RoleOwner)
28
29	// Test1 is the boards owner and its address has a user already registered
30	// so a new member must register a user with the new board name.
31	uinit.RegisterUser(cross, newName, member)
32
33	// Invite a new member that doesn't own the user that matches the new board name
34	boards2.InviteMember(cross, bid, member2, boards2.RoleOwner)
35}
36
37func main() {
38	testing.SetRealm(testing.NewUserRealm(member2))
39
40	boards2.RenameBoard(cross, name, newName)
41}
42
43// Error:
44// board name is a user name registered to a different user