@@ 314,6 314,8 @@ func (r *mutationResolver) CreateMatch(ctx context.Context) (int, error) {
}
// initialize map vote (maps and random voter)
+ // reset slice; if any element is left over, go will not reassign the value
+ voteMaps = make([]string, 0)
voteMaps = config.Maps
rand.Seed(time.Now().UTC().UnixNano())
voter := rand.Intn(2)
@@ 416,6 418,10 @@ func (r *mutationResolver) VetoMap(ctx context.Context, mapArg *string) (*model.
return &mapVote, nil
}
+ if voteStatus == "" {
+ return nil, errors.New("vote has not started")
+ }
+
if voteStatus == "DONE" {
return nil, errors.New("vote is done")
}
@@ 537,6 543,11 @@ func (r *queryResolver) GetTeams(ctx context.Context, id *int) (*model.Teams, er
return nil, database.CheckErrorCode(err)
}
+ // e.g. no teams yet
+ if len(team1) != 5 {
+ return nil, errors.New("no teams yet")
+ }
+
// Team 2
if id != nil {
// get match by id