50 lines
1.4 KiB
Go
50 lines
1.4 KiB
Go
package result
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/SamuelTariku/FortuneBet-Backend/internal/domain"
|
|
)
|
|
|
|
func TestEvaluateFootballOutcome(t *testing.T) {
|
|
service := &Service{} // or your real logger
|
|
|
|
// Mock outcome
|
|
outcome := domain.BetOutcome{
|
|
ID: 1,
|
|
BetID: 1,
|
|
EventID: 1001,
|
|
OddID: 2001,
|
|
SportID: 1, // Assuming 1 = Football
|
|
HomeTeamName: "Manchester",
|
|
AwayTeamName: "Liverpool",
|
|
MarketID: int64(domain.FOOTBALL_FULL_TIME_RESULT),
|
|
MarketName: "Full Time Result",
|
|
Odd: 1.75,
|
|
OddName: "2", // Home win
|
|
OddHeader: "1",
|
|
OddHandicap: "",
|
|
Status: domain.OUTCOME_STATUS_PENDING, // Initial status
|
|
Expires: time.Now().Add(24 * time.Hour),
|
|
}
|
|
|
|
// Parsed result (simulate Bet365 JSON)
|
|
finalScore := struct{ Home, Away int }{Home: 2, Away: 1}
|
|
firstHalfScore := struct{ Home, Away int }{Home: 1, Away: 1}
|
|
secondHalfScore := struct{ Home, Away int }{Home: 1, Away: 0}
|
|
corners := struct{ Home, Away int }{Home: 5, Away: 3}
|
|
halfTimeCorners := struct{ Home, Away int }{Home: 2, Away: 2}
|
|
events := []map[string]string{
|
|
{"type": "goal", "team": "home", "minute": "23"},
|
|
{"type": "goal", "team": "away", "minute": "34"},
|
|
}
|
|
|
|
// Act
|
|
status, _ := service.evaluateFootballOutcome(outcome, finalScore, firstHalfScore, secondHalfScore, corners, halfTimeCorners, events)
|
|
|
|
fmt.Printf("\n\nBet Outcome: %v\n\n", &status)
|
|
|
|
}
|