github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/systests/team_role_map_test.go (about) 1 package systests 2 3 import ( 4 keybase1 "github.com/keybase/client/go/protocol/keybase1" 5 "github.com/keybase/client/go/teams" 6 "github.com/stretchr/testify/require" 7 "testing" 8 "time" 9 ) 10 11 func TestTeamRoleMap(t *testing.T) { 12 tt := newTeamTester(t) 13 defer tt.cleanup() 14 15 tt.addUser("ann") 16 tt.addUser("bob") 17 18 teamID, teamName := tt.users[0].createTeam2() 19 tt.users[0].addTeamMember(teamName.String(), tt.users[1].username, keybase1.TeamRole_ADMIN) 20 21 expected := keybase1.TeamRoleMapAndVersion{ 22 Teams: make(map[keybase1.TeamID]keybase1.TeamRolePair), 23 Version: keybase1.UserTeamVersion(1), 24 } 25 expected.Teams[teamID] = keybase1.TeamRolePair{ 26 Role: keybase1.TeamRole_ADMIN, 27 ImplicitRole: keybase1.TeamRole_NONE, 28 } 29 30 select { 31 case vers := <-tt.users[1].notifications.teamRoleMapCh: 32 t.Logf("got notification") 33 require.Equal(t, expected.Version, vers) 34 case <-time.After(10 * time.Second): 35 t.Fatal("failed to get notification after 10s wait") 36 } 37 38 pollForTrue(t, tt.users[1].tc.G, func(i int) bool { 39 list := tt.users[1].tc.G.GetTeamRoleMapManager().(*teams.TeamRoleMapManager).Query() 40 if list != nil && list.Data.Version == expected.Version { 41 require.Equal(t, expected, list.Data) 42 return true 43 } 44 return false 45 }) 46 }