z_2_a_filetest.gno

1.57 Kb ยท 77 lines
 1// PKGPATH: gno.land/r/demo/groups_test
 2package groups_test
 3
 4// SEND: 1000000ugnot
 5
 6import (
 7	"std"
 8	"testing"
 9
10	"gno.land/p/demo/testutils"
11	"gno.land/r/demo/groups"
12	users "gno.land/r/gnoland/users/v1"
13)
14
15var gid groups.GroupID
16
17const admin = std.Address("g1manfred47kzduec920z88wfr64ylksmdcedlf5")
18
19func main() {
20	caller := std.OriginCaller() // main
21	testing.SetRealm(std.NewUserRealm(caller))
22	users.Register("main123")
23
24	test1 := testutils.TestAddress("gnouser1")
25	testing.SetOriginCaller(test1)
26	testing.SetRealm(std.NewUserRealm(test1))
27	users.Register("test123")
28
29	test2 := testutils.TestAddress("gnouser2")
30	testing.SetOriginCaller(test2)
31	testing.SetRealm(std.NewUserRealm(test2))
32	users.Register("test223")
33
34	test3 := testutils.TestAddress("gnouser3")
35	testing.SetOriginCaller(test3)
36	testing.SetRealm(std.NewUserRealm(test3))
37	users.Register("test323")
38
39	testing.SetOriginCaller(caller)
40	testing.SetRealm(std.NewUserRealm(caller))
41
42	gid = groups.CreateGroup("test_group")
43	println(groups.Render("test_group"))
44
45	groups.AddMember(gid, test2.String(), 42, "metadata3")
46
47	groups.DeleteMember(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 m=+1234567890.000000001
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 m=+1234567890.000000001
72//
73// Group Last MemberID: 0000000001
74//
75// Group Members:
76//
77//