generated from VLADIMIR/template
fix
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"evening_detective_server/internal/services/game_service"
|
||||
)
|
||||
|
||||
func TestMapTeamResults(t *testing.T) {
|
||||
sc := 5
|
||||
results := []game_service.TeamResult{
|
||||
{
|
||||
Team: &game_service.Team{
|
||||
ID: 1,
|
||||
Name: "Команда А",
|
||||
Status: "play",
|
||||
ActionsCount: 7,
|
||||
},
|
||||
Answers: []game_service.AnswerScore{
|
||||
{QuestionCode: "q1", Text: "ответ", Score: &sc},
|
||||
},
|
||||
TotalScore: 5,
|
||||
Place: 1,
|
||||
},
|
||||
}
|
||||
|
||||
got := mapTeamResults(results)
|
||||
if len(got) != 1 {
|
||||
t.Fatalf("len(mapTeamResults) = %d, want 1", len(got))
|
||||
}
|
||||
row := got[0]
|
||||
if row.Team == nil || row.Team.Id != 1 || row.Team.Name != "Команда А" {
|
||||
t.Fatalf("row.Team = %+v, want id 1, name Команда А", row.Team)
|
||||
}
|
||||
// actionsCount продублирован на уровне строки таблицы.
|
||||
if row.ActionsCount != 7 {
|
||||
t.Fatalf("row.ActionsCount = %d, want 7", row.ActionsCount)
|
||||
}
|
||||
if row.TotalScore != 5 || row.Place != 1 {
|
||||
t.Fatalf("row.TotalScore = %d, row.Place = %d; want 5 и 1", row.TotalScore, row.Place)
|
||||
}
|
||||
if len(row.Answers) != 1 || row.Answers[0].QuestionCode != "q1" {
|
||||
t.Fatalf("row.Answers = %+v, want один ответ q1", row.Answers)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user