Skip to content

Commit

Permalink
fix: add check for equality of fetched teams and renamed teams
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksandrMatsko committed Nov 13, 2024
1 parent 34caa71 commit 45a0103
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/cli/teams_names.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"encoding/json"
"errors"
"fmt"
"strconv"
"strings"
Expand All @@ -17,6 +18,9 @@ const (
teamsByNamesKey = "moira-teams-by-names"
)

var errTeamsCountAndUniqueNamesCountMismatch = errors.New(
"count of teams does not match count of unique names after transformation")

// fillTeamNamesHash does the following
// 1. Get all teams from DB.
// 2. Group teams with same names.
Expand Down Expand Up @@ -46,6 +50,10 @@ func fillTeamNamesHash(logger moira.Logger, database moira.Database) error {

teamByUniqueName := transformTeamsByNameMap(teamsByNameMap)

if len(teamByUniqueName) != len(teamsMap) {
return errTeamsCountAndUniqueNamesCountMismatch
}

client := db.Client()
ctx := db.Context()

Expand Down

0 comments on commit 45a0103

Please sign in to comment.