z_2_a_filetest.gno

1.60 Kb ยท 75 lines
 1// PKGPATH: gno.land/p/archive/groups_test
 2package groups_test
 3
 4// SEND: 1000000ugnot
 5
 6import (
 7	"chain/runtime"
 8	"testing"
 9
10	"gno.land/p/nt/testutils"
11	"gno.land/r/archive/groups"
12	users "gno.land/r/gnoland/users/v1"
13)
14
15var gid groups.GroupID
16
17const admin = address("g1manfred47kzduec920z88wfr64ylksmdcedlf5")
18
19func main() {
20	caller := runtime.OriginCaller() // main123
21	testing.SetRealm(testing.NewUserRealm(caller))
22	users.Register(cross, "main123")
23
24	test1 := testutils.TestAddress("gnouser1")
25	testing.SetOriginCaller(test1)
26	testing.SetRealm(testing.NewUserRealm(test1))
27	users.Register(cross, "test123")
28
29	test2 := testutils.TestAddress("gnouser2")
30	testing.SetOriginCaller(test2)
31	testing.SetRealm(testing.NewUserRealm(test2))
32	users.Register(cross, "test223")
33
34	test3 := testutils.TestAddress("gnouser3")
35	testing.SetOriginCaller(test3)
36	testing.SetRealm(testing.NewUserRealm(test3))
37	users.Register(cross, "test323")
38
39	testing.SetOriginCaller(caller)
40	testing.SetRealm(testing.NewUserRealm(caller))
41
42	gid = groups.CreateGroup(cross, "test_group")
43	println(groups.Render("test_group"))
44
45	groups.AddMember(cross, gid, test2.String(), 42, "metadata3")
46
47	groups.DeleteMember(cross, gid, 0)
48	println(groups.RenderGroup(gid))
49}
50
51// Output:
52// Group ID: 0000000001
53//
54// Group Name: test_group
55//
56// Group Creator: main123
57//
58// Group createdAt: 2009-02-13 23:31:30 +0000 UTC
59//
60// Group Last MemberID: 0000000000
61//
62// Group Members:
63//
64//
65// Group ID: 0000000001
66//
67// Group Name: test_group
68//
69// Group Creator: main123
70//
71// Group createdAt: 2009-02-13 23:31:30 +0000 UTC
72//
73// Group Last MemberID: 0000000001
74//
75// Group Members: