Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / internal/modules/ontology/adapters/calc_test.go |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | internal/modules/ontology/adapters/calc_test.go |
| Original SHA-256 | 0bd8fda79f2095336d802241d3a35143c8dbdd1cd4cdd2e68b008bd83c71954f |
| Git blob SHA | 0857242ad5f553b708c7b1ff64a2fdda1a8c8b72 |
| Reading-copy SHA-256 | 0bd8fda79f2095336d802241d3a35143c8dbdd1cd4cdd2e68b008bd83c71954f |
Every recorded occurrence
These 20 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/ontology/adapters/calc_test.go | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/calc_test.go | collision-deconfliction | 4ee5a09972608ed89f8377c6665542d5f450f0a6 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/calc_test.go | ws6-retrieval | 6c56e29231ec05735927fa265c97d517499dfeaf | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/calc_test.go | m5-price-to-win | 41000ad30fff4129fdaf5ec84e15ba14c27d4890 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/calc_test.go | ws1-ontology-sync | b596f449a32a1016fbd403c36505cc00a1ac9ee6 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/calc_test.go | master | 1e9249840a4302ec82e123b9c9cb6f75badea3e4 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/calc_test.go | ws8-teaching-loop | c823f0fb6bb2aba0f39001eb6de96f4000d9321f | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/calc_test.go | mag-substrate | b82c7100a492dec67dfd1eda6b3f53def859be35 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/calc_test.go | ws3-clearance | 4b8e7ce594c068621867f9c9deed0ec64ae6c553 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/calc_test.go | phase2-eval-fairness | d361af254701975fe239927656ababb56374655e | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/calc_test.go | time-to-fill-survival | b66e1e505863d4f17741a4b9ede73509e45bd6c6 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/calc_test.go | graphrag-foundation | b0ddeb9f633fd138d09309d1a17b7d13bc3a67f7 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/calc_test.go | ws9-bench-ingestion | f585a9ef32fa554663ce1fba9a414a54b6e49cf0 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/calc_test.go | ws2-alias-relationship | e4dada4601c6eb101830f9d223a9655dfa120616 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/calc_test.go | presentation-readiness | eb574acaa29d71ce4d0f852572e87c275c79fdb7 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/calc_test.go | vendor-intelligence | fe9796a19c261951d3f2565206c0c1b5ac294465 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/calc_test.go | ws7-federal-signal | 6a9f6ce9cfb13345ffb47770d4960e7c2d9c17c2 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/calc_test.go | phase2-connectors | e038d4c687aec16f8bd9bc4d907eea14d91f8704 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/calc_test.go | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/calc_test.go | capture-readiness | bae6af7cb2997e819174a9e9cfff5e16067a1975 | Open original |
Recovered source transcript
Download complete source text ↓185 lines · 5.8 KB
package adapters
import (
"context"
"errors"
"net/http"
"net/http/httptest"
"sort"
"strings"
"testing"
"github.com/missionworkforce/missionmatch/internal/modules/ontology"
)
// calcFixture is a minimal GSA CALC v3 ceiling rates response shaped exactly like the real
// Elasticsearch backed API (confirmed from https://api.gsa.gov/acquisition/calc/v3/api/ceilingrates/?q=engineer).
// The labor category is at hits.hits[]._source.labor_category.
// Two results share "Software Engineer I" to exercise deduplication; one is distinct.
const calcFixture = `{
"took": 3,
"timed_out": false,
"_shards": {"total": 1, "successful": 1, "skipped": 0, "failed": 0},
"hits": {
"total": {"value": 3, "relation": "eq"},
"hits": [
{
"_index": "calc",
"_id": "100001",
"_score": 1.0,
"_source": {
"labor_category": "Software Engineer I",
"vendor_name": "Acme Federal LLC",
"current_price": 85.00,
"education_level": "Bachelors",
"min_years_experience": 3,
"security_clearance": "None",
"worksite": "Both"
}
},
{
"_index": "calc",
"_id": "100002",
"_score": 1.0,
"_source": {
"labor_category": "Software Engineer I",
"vendor_name": "Beta Solutions Inc",
"current_price": 92.00,
"education_level": "Masters",
"min_years_experience": 5,
"security_clearance": "Secret",
"worksite": "Customer Site"
}
},
{
"_index": "calc",
"_id": "100003",
"_score": 1.0,
"_source": {
"labor_category": "Systems Analyst II",
"vendor_name": "GovCon Corp",
"current_price": 110.00,
"education_level": "Bachelors",
"min_years_experience": 7,
"security_clearance": "TS",
"worksite": "Contractor Site"
}
}
]
}
}`
// TestParseCALC feeds a literal fixture (two results with the same labor category and one
// distinct) to parseCALC and confirms the returned slice contains the two distinct strings.
func TestParseCALC(t *testing.T) {
got, err := parseCALC([]byte(calcFixture))
if err != nil {
t.Fatalf("parseCALC returned an error: %v", err)
}
// The fixture has 3 hits but only 2 distinct labor categories.
// parseCALC returns them deduplicated; order is not guaranteed.
want := map[string]bool{
"Software Engineer I": true,
"Systems Analyst II": true,
}
if len(got) != 2 {
t.Fatalf("want 2 distinct labor categories, got %d: %v", len(got), got)
}
for _, lc := range got {
if !want[lc] {
t.Errorf("unexpected labor category %q", lc)
}
}
}
// TestParseCALCEmpty confirms parseCALC handles an empty hits.hits array without error.
func TestParseCALCEmpty(t *testing.T) {
empty := `{"hits":{"total":{"value":0,"relation":"eq"},"hits":[]}}`
got, err := parseCALC([]byte(empty))
if err != nil {
t.Fatalf("parseCALC on empty hits returned error: %v", err)
}
if len(got) != 0 {
t.Fatalf("want 0 results for empty hits, got %d", len(got))
}
}
// TestCALCSourceDedupes stands up an httptest.Server returning the calcFixture for every
// query. It uses a two item seed list where both queries return the same fixture, confirming
// that Fetch deduplicates across seeds and yields each distinct labor category exactly once.
func TestCALCSourceDedupes(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
_, _ = w.Write([]byte(calcFixture))
}))
defer srv.Close()
// Two seeds that both return the same fixture: total 4 hits but only 2 distinct categories.
src := NewCALCSource(srv.URL+"/", "", []string{"engineer", "analyst"}, srv.Client())
var records []ontology.VocabRecord
err := src.Fetch(context.Background(), func(r ontology.VocabRecord) error {
records = append(records, r)
return nil
})
if err != nil {
t.Fatalf("Fetch returned an error: %v", err)
}
// Exactly 2 distinct labor categories must be yielded regardless of seed count.
if len(records) != 2 {
t.Fatalf("want 2 records (deduplicated across seeds), got %d", len(records))
}
// Sort for deterministic assertion order.
sort.Slice(records, func(i, j int) bool { return records[i].Term < records[j].Term })
wantTerms := []string{"Software Engineer I", "Systems Analyst II"}
for i, r := range records {
if r.Kind != ontology.KindLaborCategory {
t.Errorf("record[%d]: want Kind %q, got %q", i, ontology.KindLaborCategory, r.Kind)
}
if r.SourceName != "GSA CALC" {
t.Errorf("record[%d]: want SourceName %q, got %q", i, "GSA CALC", r.SourceName)
}
if r.Category != "labor_category" {
t.Errorf("record[%d]: want Category %q, got %q", i, "labor_category", r.Category)
}
if r.Term != wantTerms[i] {
t.Errorf("record[%d]: want Term %q, got %q", i, wantTerms[i], r.Term)
}
}
// SourceRecordID must be the lowercased labor category text.
byTerm := make(map[string]ontology.VocabRecord, len(records))
for _, r := range records {
byTerm[r.Term] = r
}
for _, term := range wantTerms {
r := byTerm[term]
wantID := strings.ToLower(term)
if r.SourceRecordID != wantID {
t.Errorf("Term %q: want SourceRecordID %q, got %q", term, wantID, r.SourceRecordID)
}
}
}
// TestCALCSourceThrottled confirms that a 429 response is surfaced as ontology.ErrThrottled.
func TestCALCSourceThrottled(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusTooManyRequests)
}))
defer srv.Close()
src := NewCALCSource(srv.URL+"/", "", []string{"engineer"}, srv.Client())
err := src.Fetch(context.Background(), func(r ontology.VocabRecord) error { return nil })
if err == nil {
t.Fatal("expected an error on 429, got nil")
}
// The error must wrap or equal ErrThrottled.
if !errors.Is(err, ontology.ErrThrottled) {
t.Errorf("want ErrThrottled, got %v", err)
}
}