31 lines
970 B
Go
31 lines
970 B
Go
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)
|
|
}
|
|
})
|
|
}
|
|
}
|