package adapters import ( "testing" "time" "github.com/shopspring/decimal" oppintel "github.com/missionworkforce/missionmatch/internal/modules/opportunity_intelligence" "github.com/missionworkforce/missionmatch/internal/platform/samawards" ) func TestFromSAMAward(t *testing.T) { signed := time.Date(2025, 5, 7, 0, 0, 0, 0, time.UTC) total := decimal.RequireFromString("59400") a := samawards.Award{ UniqueKey: "W900KK25FA080|P00003|0", PIID: "W900KK25FA080", AwardeeName: "ASK SAGE, INC.", AwardeeUEI: "W9X4EWLUBAW1", TotalValue: &total, Department: "DEPT OF DEFENSE", Subtier: "DEPT OF DEFENSE", NAICSCode: "541512", DateSigned: &signed, } r := fromSAMAward(a, time.Now()) if r.Kind != oppintel.KindContractAward { t.Fatalf("kind = %s", r.Kind) } if r.SourceName != "SAM Contract Awards" { t.Fatalf("source = %q", r.SourceName) } if r.SourceRecordID != "W900KK25FA080|P00003|0" { t.Fatalf("source record id = %q", r.SourceRecordID) } if r.DedupeKey != "W900KK25FA080" { t.Fatalf("dedupe = %q", r.DedupeKey) } if r.EstimatedValue == nil || !r.EstimatedValue.Equal(total) { t.Fatalf("value = %v", r.EstimatedValue) } if r.ValueSource != "sam" { t.Fatalf("value source = %q", r.ValueSource) } if r.IncumbentName != "ASK SAGE, INC." || r.IncumbentUEI != "W9X4EWLUBAW1" { t.Fatalf("incumbent wrong: %+v", r) } if r.AwardDate == nil || !r.AwardDate.Equal(signed) { t.Fatalf("award date = %v", r.AwardDate) } } func TestFromSAMAwardFallsBackToObligated(t *testing.T) { ob := decimal.RequireFromString("100") a := samawards.Award{PIID: "X", UniqueKey: "X", ObligatedValue: &ob} r := fromSAMAward(a, time.Now()) if r.EstimatedValue == nil || !r.EstimatedValue.Equal(ob) { t.Fatalf("should use the obligated amount when the ceiling is absent, got %v", r.EstimatedValue) } if r.ValueSource != "sam" { t.Fatalf("value source = %q", r.ValueSource) } } func TestFromSAMAwardNoValueStaysNil(t *testing.T) { a := samawards.Award{PIID: "X", UniqueKey: "X"} r := fromSAMAward(a, time.Now()) if r.EstimatedValue != nil { t.Fatal("no amount must stay nil, never a fabricated zero") } if r.ValueSource != "" { t.Fatal("no value source without a value") } }