fix
This commit is contained in:
@@ -190,6 +190,37 @@ func TestApplyV1ProcessItemIDsDualMode(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestV1ProcessJobItemMarshalJSONOmitsInternals(t *testing.T) {
|
||||
item := V1ProcessJobItem{
|
||||
"ean": "1",
|
||||
"status": "processed",
|
||||
"name": "T",
|
||||
"id": "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb",
|
||||
"ai_enhance": true,
|
||||
"finish_reason": "stop",
|
||||
"enhance_input_hash": "deadbeef",
|
||||
"field_sources": map[string]any{"enhance_input_hash": "deadbeef"},
|
||||
"prompt_tokens": 9,
|
||||
"worker": "river",
|
||||
}
|
||||
raw, err := json.Marshal(item)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
s := string(raw)
|
||||
for _, junk := range []string{
|
||||
`"id"`, `"ai_enhance"`, `"finish_reason"`, `"enhance_input_hash"`,
|
||||
`"field_sources"`, `"prompt_tokens"`, `"worker"`, "deadbeef",
|
||||
} {
|
||||
if strings.Contains(s, junk) {
|
||||
t.Fatalf("internal %q leaked in JSON: %s", junk, s)
|
||||
}
|
||||
}
|
||||
if !strings.Contains(s, `"ean":"1"`) || !strings.Contains(s, `"name":"T"`) {
|
||||
t.Fatalf("public fields missing: %s", s)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatJobStatusResponseAddsItems(t *testing.T) {
|
||||
jobID := mustParseTestUUID(t, "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa")
|
||||
job := Job{ID: jobID, Status: "completed", TotalProducts: 1}
|
||||
@@ -218,3 +249,33 @@ func mustParseTestUUID(t *testing.T, s string) uuid.UUID {
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
func TestCompanyOmitsSEOMetaLookup(t *testing.T) {
|
||||
t.Parallel()
|
||||
a1 := mustParseTestUUID(t, "604f23a8-b66e-4b21-8b45-0d72b68f4790")
|
||||
other := mustParseTestUUID(t, "11111111-1111-1111-1111-111111111111")
|
||||
cases := []struct {
|
||||
name string
|
||||
id uuid.UUID
|
||||
legacy string
|
||||
coName string
|
||||
prompts bool
|
||||
wantOmit bool
|
||||
}{
|
||||
{name: "ordinary", id: other, coName: "Acme", wantOmit: false},
|
||||
{name: "a1_uuid", id: a1, wantOmit: true},
|
||||
{name: "demo_by_name", id: other, coName: "Platform Demo", wantOmit: true},
|
||||
{name: "demo_by_name_case", id: other, coName: " platform DEMO ", wantOmit: true},
|
||||
{name: "a1_prompt_markers", id: other, coName: "Acme", prompts: true, wantOmit: true},
|
||||
{name: "a1_legacy_id", id: other, legacy: "97e1a309-3d23-4aa2-b518-8e8d7afdfec7", wantOmit: true},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
got := CompanyOmitsSEOMetaLookup(tc.id, tc.legacy, tc.coName, tc.prompts)
|
||||
if got != tc.wantOmit {
|
||||
t.Fatalf("got %v want %v", got, tc.wantOmit)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user