package result import ( "testing" "github.com/SamuelTariku/FortuneBet-Backend/internal/domain" ) func TestEvaluateFullTimeResult(t *testing.T) { tests := []struct { name string outcome domain.BetOutcome score struct{ Home, Away int } expected domain.OutcomeStatus }{ {"Home win", domain.BetOutcome{OddName: "1"}, struct{ Home, Away int }{2, 1}, domain.OUTCOME_STATUS_WIN}, {"Away win", domain.BetOutcome{OddName: "2"}, struct{ Home, Away int }{1, 2}, domain.OUTCOME_STATUS_WIN}, {"Draw", domain.BetOutcome{OddName: "Draw"}, struct{ Home, Away int }{1, 1}, domain.OUTCOME_STATUS_WIN}, {"Home selected, but Draw", domain.BetOutcome{OddName: "1"}, struct{ Home, Away int }{1, 1}, domain.OUTCOME_STATUS_LOSS}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { status, _ := evaluateFullTimeResult(tt.outcome, tt.score) if status != tt.expected { t.Errorf("expected %d, got %d", tt.expected, status) } }) } } func TestEvaluateTotalLegs(t *testing.T) { tests := []struct { Name string outcome domain.BetOutcome score struct{ Home, Away int } expected domain.OutcomeStatus }{ {"OverTotalLegs", domain.BetOutcome{OddName: "3", OddHeader: "Over"}, struct{ Home, Away int }{2, 4}, domain.OUTCOME_STATUS_WIN}, {"OverTotalLegs", domain.BetOutcome{OddName: "3", OddHeader: "Under"}, struct{ Home, Away int }{2, 4}, domain.OUTCOME_STATUS_LOSS}, {"UnderTotalLegs", domain.BetOutcome{OddName: "7", OddHeader: "Under"}, struct{ Home, Away int }{2, 3}, domain.OUTCOME_STATUS_WIN}, } for _, tt := range tests { t.Run(tt.Name, func(t *testing.T) { status, _ := evaluateTotalLegs(tt.outcome, tt.score) if status != tt.expected { t.Errorf("expected %d, got %d", tt.expected, status) } }) } } func TestEvaluateGameLines(t *testing.T) { tests := []struct { Name string outcome domain.BetOutcome score struct{ Home, Away int } expected domain.OutcomeStatus }{ {"GameLines - Total", domain.BetOutcome{OddName: "Total", OddHandicap: "O 5.5"}, struct{ Home, Away int }{2, 4}, domain.OUTCOME_STATUS_WIN}, {"GameLines - Total", domain.BetOutcome{OddName: "Total", OddHandicap: "O 5.5"}, struct{ Home, Away int }{2, 3}, domain.OUTCOME_STATUS_LOSS}, {"GameLines - Money Line", domain.BetOutcome{OddName: "Money Line", OddHeader: "1"}, struct{ Home, Away int }{2, 3}, domain.OUTCOME_STATUS_LOSS}, {"GameLines - Money Line", domain.BetOutcome{OddName: "Money Line", OddHeader: "1"}, struct{ Home, Away int }{3, 2}, domain.OUTCOME_STATUS_WIN}, } for _, tt := range tests { t.Run(tt.Name, func(t *testing.T) { status, _ := evaluateGameLines(tt.outcome, tt.score) if status != tt.expected { t.Errorf("expected %d, got %d", tt.expected, status) } }) } } func TestFirstTeamToScore(t *testing.T) { tests := []struct { Name string outcome domain.BetOutcome events []map[string]string expected domain.OutcomeStatus }{ {"HomeScoreFirst", domain.BetOutcome{OddName: "1", HomeTeamName: "Team A", AwayTeamName: "Team B"}, []map[string]string{ {"text": "1st Goal - Team A"}, }, domain.OUTCOME_STATUS_WIN}, {"AwayScoreFirst", domain.BetOutcome{OddName: "2", HomeTeamName: "Team A", AwayTeamName: "Team B"}, []map[string]string{ {"text": "1st Goal - Team A"}, }, domain.OUTCOME_STATUS_LOSS}, {"AwayScoreFirst", domain.BetOutcome{OddName: "2", HomeTeamName: "Team A", AwayTeamName: "Team B"}, []map[string]string{ {"text": "1st Goal - Team B"}, }, domain.OUTCOME_STATUS_WIN}, } for _, tt := range tests { t.Run(tt.Name, func(t *testing.T) { status, _ := evaluateFirstTeamToScore(tt.outcome, tt.events) if status != tt.expected { t.Errorf("expected %d, got %d", tt.expected, status) } }) } }