ninth version
Deploy / Test, build and deploy (push) Failing after 1m6s

This commit is contained in:
2026-06-08 14:25:44 +00:00
parent e8b7d8e27c
commit 20cc8506ad
21 changed files with 847 additions and 148 deletions
+44
View File
@@ -2,6 +2,7 @@ package marketdata
import (
"context"
"errors"
"strings"
"testing"
"time"
@@ -9,6 +10,7 @@ import (
"github.com/shopspring/decimal"
"overnight-trading-bot/internal/domain"
"overnight-trading-bot/internal/testutil"
"overnight-trading-bot/internal/tinvest"
)
@@ -41,3 +43,45 @@ func TestLatestQuoteUsesExchangeTimestampForFreshness(t *testing.T) {
t.Fatalf("LatestQuote err=%v, want stale exchange timestamp rejection", err)
}
}
func TestBackfillDailyFailsOnAnyEligibleInstrumentError(t *testing.T) {
ctx := context.Background()
gateway := tinvest.NewFakeGateway()
repo := testutil.NewMemoryRepository()
gateway.Candles["ok"] = []domain.Candle{{
InstrumentUID: "ok",
TradeDate: time.Date(2026, 6, 8, 0, 0, 0, 0, time.UTC),
Close: decimal.NewFromInt(100),
}}
gateway.CandleErrors["bad"] = errors.New("candles unavailable")
loader := NewLoader(repo, gateway)
err := loader.BackfillDaily(ctx, []domain.Instrument{
{InstrumentUID: "ok", Ticker: "OK", Enabled: true},
{InstrumentUID: "bad", Ticker: "BAD", Enabled: true},
}, time.Date(2026, 6, 1, 0, 0, 0, 0, time.UTC), time.Date(2026, 6, 8, 0, 0, 0, 0, time.UTC))
if err == nil {
t.Fatal("expected per-instrument backfill error")
}
}
func TestBackfillMinuteFailsOnAnyEligibleInstrumentError(t *testing.T) {
ctx := context.Background()
gateway := tinvest.NewFakeGateway()
repo := testutil.NewMemoryRepository()
gateway.Candles["ok"] = []domain.Candle{{
InstrumentUID: "ok",
TradeDate: time.Date(2026, 6, 8, 18, 10, 0, 0, time.UTC),
Close: decimal.NewFromInt(100),
}}
gateway.CandleErrors["bad"] = errors.New("minute candles unavailable")
loader := NewLoader(repo, gateway)
err := loader.BackfillMinute(ctx, []domain.Instrument{
{InstrumentUID: "ok", Ticker: "OK", Enabled: true},
{InstrumentUID: "bad", Ticker: "BAD", Enabled: true},
}, time.Date(2026, 6, 8, 18, 0, 0, 0, time.UTC), time.Date(2026, 6, 8, 19, 0, 0, 0, time.UTC))
if err == nil {
t.Fatal("expected per-instrument minute backfill error")
}
}