unit test bet outcome
This commit is contained in:
parent
c637ddb321
commit
95eaed18ad
|
|
@ -4177,7 +4177,7 @@ const docTemplate = `{
|
|||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Virtual Games"
|
||||
"Veli Games"
|
||||
],
|
||||
"summary": "Veli Games webhook handler",
|
||||
"parameters": [
|
||||
|
|
|
|||
|
|
@ -4169,7 +4169,7 @@
|
|||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Virtual Games"
|
||||
"Veli Games"
|
||||
],
|
||||
"summary": "Veli Games webhook handler",
|
||||
"parameters": [
|
||||
|
|
|
|||
|
|
@ -4258,7 +4258,7 @@ paths:
|
|||
type: object
|
||||
summary: Veli Games webhook handler
|
||||
tags:
|
||||
- Virtual Games
|
||||
- Veli Games
|
||||
securityDefinitions:
|
||||
Bearer:
|
||||
in: header
|
||||
|
|
|
|||
49
internal/services/result/service_test.go
Normal file
49
internal/services/result/service_test.go
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
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)
|
||||
|
||||
}
|
||||
|
|
@ -42,7 +42,7 @@ func (h *Handler) LaunchVeliGame(c *fiber.Ctx) error {
|
|||
// HandleVeliCallback godoc
|
||||
// @Summary Veli Games webhook handler
|
||||
// @Description Processes game round settlements from Veli
|
||||
// @Tags Virtual Games
|
||||
// @Tags Veli Games
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param payload body domain.VeliCallback true "Callback payload"
|
||||
|
|
|
|||
|
|
@ -194,11 +194,11 @@ func (a *App) initAppRoutes() {
|
|||
group.Post("/webhooks/alea-play", a.authMiddleware, h.HandleAleaCallback)
|
||||
|
||||
//Veli Virtual Game Routes
|
||||
group.Get("/veli-games/launch", a.authMiddleware, h.LaunchVeliGame)
|
||||
group.Post("/webhooks/veli-games", a.authMiddleware, h.HandleVeliCallback)
|
||||
group.Get("/veli-games/launch", h.LaunchVeliGame)
|
||||
group.Post("/webhooks/veli-games", h.HandleVeliCallback)
|
||||
|
||||
// Recommendation Routes
|
||||
group.Get("/virtual-games/recommendations/:userID", a.authMiddleware, h.GetRecommendations)
|
||||
group.Get("/virtual-games/recommendations/:userID", h.GetRecommendations)
|
||||
|
||||
// Transactions /transactions
|
||||
a.fiber.Post("/transaction", a.authMiddleware, h.CreateTransaction)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user