Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / internal/modules/bidoutcomes/service_test.go |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | internal/modules/bidoutcomes/service_test.go |
| Original SHA-256 | 222e3efa0fb40553f60038e635ce7bea807575b80b6d5e7767910155d7ad067c |
| Git blob SHA | 4f184e5e36bd2ecdfa1544adcb920a88c344f2e8 |
| Reading-copy SHA-256 | 222e3efa0fb40553f60038e635ce7bea807575b80b6d5e7767910155d7ad067c |
Every recorded occurrence
These 12 records contain identical original source bytes. Their paths and revisions remain part of the archive.
| Original record | Branch or archive | Revision / identifier | Original location |
|---|---|---|---|
| Janady13/missionmatch / internal/modules/bidoutcomes/service_test.go | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / internal/modules/bidoutcomes/service_test.go | collision-deconfliction | 4ee5a09972608ed89f8377c6665542d5f450f0a6 | Open original |
| Janady13/missionmatch / internal/modules/bidoutcomes/service_test.go | m5-price-to-win | 41000ad30fff4129fdaf5ec84e15ba14c27d4890 | Open original |
| Janady13/missionmatch / internal/modules/bidoutcomes/service_test.go | master | 1e9249840a4302ec82e123b9c9cb6f75badea3e4 | Open original |
| Janady13/missionmatch / internal/modules/bidoutcomes/service_test.go | mag-substrate | b82c7100a492dec67dfd1eda6b3f53def859be35 | Open original |
| Janady13/missionmatch / internal/modules/bidoutcomes/service_test.go | time-to-fill-survival | b66e1e505863d4f17741a4b9ede73509e45bd6c6 | Open original |
| Janady13/missionmatch / internal/modules/bidoutcomes/service_test.go | graphrag-foundation | b0ddeb9f633fd138d09309d1a17b7d13bc3a67f7 | Open original |
| Janady13/missionmatch / internal/modules/bidoutcomes/service_test.go | presentation-readiness | eb574acaa29d71ce4d0f852572e87c275c79fdb7 | Open original |
| Janady13/missionmatch / internal/modules/bidoutcomes/service_test.go | vendor-intelligence | fe9796a19c261951d3f2565206c0c1b5ac294465 | Open original |
| Janady13/missionmatch / internal/modules/bidoutcomes/service_test.go | phase2-connectors | e038d4c687aec16f8bd9bc4d907eea14d91f8704 | Open original |
| Janady13/missionmatch / internal/modules/bidoutcomes/service_test.go | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
| Janady13/missionmatch / internal/modules/bidoutcomes/service_test.go | capture-readiness | bae6af7cb2997e819174a9e9cfff5e16067a1975 | Open original |
Recovered source transcript
Download complete source text ↓76 lines · 3.3 KB
package bidoutcomes
import (
"context"
"errors"
"testing"
"github.com/google/uuid"
)
// TestRecordRejectsBadResult proves the service validates the result enum BEFORE any database work: a value
// outside the allowed set (win, loss, no_bid, pending) is ErrInvalidResult, an empty result defaults to
// pending and is accepted (it reaches the nil database guard, ErrNoDatabase, not the enum guard), and a
// known good value is accepted the same way. Validation runs with a nil service db, so this needs no
// Postgres.
func TestRecordRejectsBadResult(t *testing.T) {
svc := NewService(nil, nil) // nil db: validation runs first, then the ErrNoDatabase guard
if _, err := svc.RecordBidOutcome(context.Background(), RecordInput{Result: "victory"}); !errors.Is(err, ErrInvalidResult) {
t.Fatalf("a bad result enum must be ErrInvalidResult, got %v", err)
}
// Each allowed result (and the empty default) passes validation and falls through to ErrNoDatabase.
for _, r := range []string{"", ResultPending, ResultWin, ResultLoss, ResultNoBid} {
_, err := svc.RecordBidOutcome(context.Background(), RecordInput{Result: r})
if !errors.Is(err, ErrNoDatabase) {
t.Fatalf("a valid result %q must pass validation and reach the db guard (ErrNoDatabase), got %v", r, err)
}
}
}
// TestRecordRejectsBadLinkID proves a non uuid link is rejected as ErrInvalidID before any database work,
// so a malformed opportunity, requirement, or slate id is a clean 422 rather than a raw bind error.
func TestRecordRejectsBadLinkID(t *testing.T) {
svc := NewService(nil, nil)
for name, in := range map[string]RecordInput{
"opportunity": {Result: ResultWin, OpportunityID: "not_a_uuid"},
"requirement": {Result: ResultWin, RequirementID: "not_a_uuid"},
"slate": {Result: ResultWin, SlateID: "not_a_uuid"},
"row": {Result: ResultWin, ID: "not_a_uuid"},
} {
if _, err := svc.RecordBidOutcome(context.Background(), in); !errors.Is(err, ErrInvalidID) {
t.Fatalf("a bad %s link must be ErrInvalidID, got %v", name, err)
}
}
// A valid uuid link passes validation and reaches the db guard.
if _, err := svc.RecordBidOutcome(context.Background(), RecordInput{Result: ResultWin, OpportunityID: uuid.NewString()}); !errors.Is(err, ErrNoDatabase) {
t.Fatalf("a valid uuid link must pass validation, got %v", err)
}
}
// TestUpdateRejectsBadResult proves the update path validates the result enum the same way.
func TestUpdateRejectsBadResult(t *testing.T) {
svc := NewService(nil, nil)
if _, err := svc.UpdateBidOutcome(context.Background(), uuid.New(), UpdateInput{Result: "maybe"}); !errors.Is(err, ErrInvalidResult) {
t.Fatalf("a bad result enum must be ErrInvalidResult, got %v", err)
}
if _, err := svc.UpdateBidOutcome(context.Background(), uuid.New(), UpdateInput{Result: ResultLoss}); !errors.Is(err, ErrNoDatabase) {
t.Fatalf("a valid result must pass validation and reach the db guard, got %v", err)
}
}
// TestIsValidResult pins the closed set of allowed result values.
func TestIsValidResult(t *testing.T) {
for _, r := range []string{ResultPending, ResultWin, ResultLoss, ResultNoBid} {
if !IsValidResult(r) {
t.Errorf("%q must be a valid result", r)
}
}
for _, r := range []string{"", "Win", "WIN", "withdrawn", "pending "} {
if IsValidResult(r) {
t.Errorf("%q must NOT be a valid result", r)
}
}
}