z_1_a_filetest.gno
1.47 Kb ยท 63 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() // main
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(gid)
44
45 groups.AddMember(cross, gid, test3.String(), 32, "i am from UAE")
46 println(groups.Render("test_group"))
47}
48
49// Output:
50// 1
51// Group ID: 0000000001
52//
53// Group Name: test_group
54//
55// Group Creator: main123
56//
57// Group createdAt: 2009-02-13 23:31:30 +0000 UTC
58//
59// Group Last MemberID: 0000000001
60//
61// Group Members:
62//
63// [0000000000, g1vahx7atnv4erxh6lta047h6lta047h6ll85gpy, 32, i am from UAE, 2009-02-13 23:31:30 +0000 UTC],