-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9683 from vegaprotocol/9679-add-team-support-for-…
…referrals Adding teams support for referrals
- Loading branch information
Showing
5 changed files
with
118 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package steps | ||
|
||
import ( | ||
"fmt" | ||
"sort" | ||
|
||
"code.vegaprotocol.io/vega/core/teams" | ||
"github.com/cucumber/godog" | ||
) | ||
|
||
func TheTeamHasTheFollowingMembers(teamsEngine *teams.Engine, team string, table *godog.Table) error { | ||
// Get a list of all the parties in a team | ||
members := teamsEngine.GetTeamMembers(team, 0) | ||
rows := []string{} | ||
for _, r := range parseMembersTable(table) { | ||
row := newMembersRow(r) | ||
rows = append(rows, row.Party()) | ||
} | ||
sort.Strings(members) | ||
sort.Strings(rows) | ||
|
||
// Do we have the same amount of parties in each list? | ||
if len(members) != len(rows) { | ||
return fmt.Errorf("different number of team members between the table (%d) and the engine (%d)", len(rows), len(members)) | ||
} | ||
|
||
// Do we have the same members in each list? | ||
for i, r := range members { | ||
if r != rows[i] { | ||
return fmt.Errorf("party details are different (%s != %s)", r, rows[i]) | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func parseMembersTable(table *godog.Table) []RowWrapper { | ||
return StrictParseTable(table, []string{ | ||
"party", | ||
}, []string{}) | ||
} | ||
|
||
type membersRow struct { | ||
row RowWrapper | ||
} | ||
|
||
func newMembersRow(r RowWrapper) membersRow { | ||
row := membersRow{ | ||
row: r, | ||
} | ||
return row | ||
} | ||
|
||
func (r membersRow) Party() string { | ||
return r.row.MustStr("party") | ||
} |