Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / internal/integration/connector_icims_integration_test.go |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | internal/integration/connector_icims_integration_test.go |
| Original SHA-256 | a4a236480337ac8bfa93348c15a0a5fdabe97e5938673a883abc9a72b8288d16 |
| Git blob SHA | 058bda622a2e70b3f993ceab9cf2b16a993bf388 |
| Reading-copy SHA-256 | a4a236480337ac8bfa93348c15a0a5fdabe97e5938673a883abc9a72b8288d16 |
Every recorded occurrence
These 9 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/integration/connector_icims_integration_test.go | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / internal/integration/connector_icims_integration_test.go | collision-deconfliction | 4ee5a09972608ed89f8377c6665542d5f450f0a6 | Open original |
| Janady13/missionmatch / internal/integration/connector_icims_integration_test.go | master | 1e9249840a4302ec82e123b9c9cb6f75badea3e4 | Open original |
| Janady13/missionmatch / internal/integration/connector_icims_integration_test.go | time-to-fill-survival | b66e1e505863d4f17741a4b9ede73509e45bd6c6 | Open original |
| Janady13/missionmatch / internal/integration/connector_icims_integration_test.go | presentation-readiness | eb574acaa29d71ce4d0f852572e87c275c79fdb7 | Open original |
| Janady13/missionmatch / internal/integration/connector_icims_integration_test.go | vendor-intelligence | fe9796a19c261951d3f2565206c0c1b5ac294465 | Open original |
| Janady13/missionmatch / internal/integration/connector_icims_integration_test.go | phase2-connectors | e038d4c687aec16f8bd9bc4d907eea14d91f8704 | Open original |
| Janady13/missionmatch / internal/integration/connector_icims_integration_test.go | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
| Janady13/missionmatch / internal/integration/connector_icims_integration_test.go | capture-readiness | bae6af7cb2997e819174a9e9cfff5e16067a1975 | Open original |
Recovered source transcript
Download complete source text ↓117 lines · 4.8 KB
//go:build integration
// Enterprise connector (iCIMS) integration. Proves at runtime against a REAL Postgres and a fake iCIMS server
// what the unit tests cannot: connector.Sync ingests a page of candidates as STRUCTURED scoring inputs (skills
// as rows) plus a sourcing_log provenance row each, advances the connector_sync_state watermark, and is
// idempotent (a re run dedupes rather than duplicating), all through the proven sourcing path with clearance
// left unknown. Migration 0038 (connector_sync_state) must be applied.
//
// Run: go test -tags=integration ./internal/integration/ -run ConnectorICIMS -v
// Env: MM_MIGRATOR_DSN.
package integration
import (
"context"
"net/http"
"net/http/httptest"
"testing"
"github.com/google/uuid"
"github.com/missionworkforce/missionmatch/internal/platform/connector"
"github.com/missionworkforce/missionmatch/internal/platform/extraction"
)
// fakeICIMSServer serves a bearer token and one page of two candidates (ignoring updatedSince, so a re run sees
// the same records and must dedupe).
func fakeICIMSServer() *httptest.Server {
mux := http.NewServeMux()
mux.HandleFunc("/oauth/token", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
_, _ = w.Write([]byte(`{"access_token":"tok","expires_in":3600}`))
})
mux.HandleFunc("/customers/CUST1/search/people", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
_, _ = w.Write([]byte(`{"people":[
{"id":"ic-1","name":"Connector Alpha","title":"RMF Engineer","location":"Honolulu HI","skills":["rmf","cloud security"],"years":7,"updated":"2026-02-01T00:00:00Z"},
{"id":"ic-2","name":"Connector Beta","title":"ISSO","location":"Santa Fe NM","skills":["ato"],"years":9,"updated":"2026-03-10T00:00:00Z"}
],"nextPage":""}`))
})
return httptest.NewServer(mux)
}
func TestConnectorICIMSSyncIngestsAndAdvancesWatermark(t *testing.T) {
ctx := context.Background()
org := seedOrg(t)
srv := fakeICIMSServer()
defer srv.Close()
c := connector.NewICIMS("CUST1", "cid", "secret", srv.URL, srv.Client())
ext := extraction.NewDeterministic()
res, err := connector.Sync(ctx, migrator, org, c, ext, "test legal basis", 1000)
if err != nil {
t.Fatalf("sync: %v", err)
}
if res.Synced != 2 {
t.Fatalf("the first sync must ingest 2 candidates, got %d", res.Synced)
}
// Two external candidates exist for the org, tagged with the iCIMS external ids.
if n := countExternal(t, org); n != 2 {
t.Fatalf("2 external candidates must be created, got %d", n)
}
// Their structured skills were attached (a connector record is a real scoring input, not a headline).
var skillCount int
if err := migrator.QueryRow(ctx,
`SELECT count(*) FROM candidate_skills cs
JOIN candidates c ON c.id = cs.candidate_id
WHERE c.organization_id=$1 AND c.external_id IN ('ic-1','ic-2')`, org).Scan(&skillCount); err != nil {
t.Fatalf("count skills: %v", err)
}
if skillCount < 3 {
t.Fatalf("the structured skills must be attached (rmf, cloud security, ato), got %d", skillCount)
}
// A sourcing_log provenance row exists per record.
var logCount int
if err := migrator.QueryRow(ctx,
`SELECT count(*) FROM sourcing_log WHERE organization_id=$1 AND external_id IN ('ic-1','ic-2') AND provider='icims'`, org).Scan(&logCount); err != nil {
t.Fatalf("count sourcing_log: %v", err)
}
if logCount != 2 {
t.Fatalf("a sourcing_log row must be written per record, got %d", logCount)
}
// The watermark advanced to the max updated timestamp seen (compared as an instant, timezone independent).
var watermarkOK bool
if err := migrator.QueryRow(ctx,
`SELECT watermark = '2026-03-10T00:00:00Z'::timestamptz FROM connector_sync_state WHERE organization_id=$1 AND connector_name='icims'`, org).Scan(&watermarkOK); err != nil {
t.Fatalf("read watermark: %v", err)
}
if !watermarkOK {
t.Fatal("the watermark must advance to the max updated instant 2026-03-10T00:00:00Z")
}
// Idempotency: a second sync over the same records dedupes (enriches), it does not create duplicates.
res2, err := connector.Sync(ctx, migrator, org, c, ext, "test legal basis", 1000)
if err != nil {
t.Fatalf("second sync: %v", err)
}
if res2.Synced != 2 {
t.Fatalf("the second sync still processes 2 records, got %d", res2.Synced)
}
if n := countExternal(t, org); n != 2 {
t.Fatalf("a re run must not duplicate candidates, still expect 2, got %d", n)
}
}
// countExternal counts the org's external candidates carrying the iCIMS ids.
func countExternal(t *testing.T, org uuid.UUID) int {
t.Helper()
var n int
if err := migrator.QueryRow(context.Background(),
`SELECT count(*) FROM candidates WHERE organization_id=$1 AND external_id IN ('ic-1','ic-2')`, org).Scan(&n); err != nil {
t.Fatalf("count external candidates: %v", err)
}
return n
}