diff --git a/tide/normalize.go b/tide/normalize.go index 07ee71d..b847447 100644 --- a/tide/normalize.go +++ b/tide/normalize.go @@ -55,6 +55,16 @@ func maskLeaf(path string, val any, step Step, diffs *[]Diff) any { if key == "slug" || disabledPath(step, path, key) { return val } + if key == "collection_key" { + if val == nil { + return nil + } + if _, ok := val.(string); !ok { + *diffs = append(*diffs, Diff{Path: path, Expected: "string collection_key", Actual: formatValue(val)}) + return val + } + return maskID + } if isDateKey(key) { return maskDate(path, val, diffs) } @@ -97,7 +107,7 @@ func maskIDValue(path string, val any, diffs *[]Diff) any { } func isDateKey(key string) bool { - return strings.HasSuffix(key, "_at") + return strings.HasSuffix(key, "_at") || key == "checkpoint" } func isIDKey(key string) bool { diff --git a/tide/normalize_test.go b/tide/normalize_test.go index 944de80..bc59445 100644 --- a/tide/normalize_test.go +++ b/tide/normalize_test.go @@ -20,6 +20,11 @@ func TestNormalizeDateIDAndDisable(t *testing.T) { if diffs := compareBodies(Response{Headers: jsonCT(), Body: Body(nullID)}, Response{Headers: jsonCT(), Body: Body(nullID)}, step); len(diffs) != 0 { t.Fatalf("null *_id must pass: %+v", diffs) } + syncA := []byte(`{"collection_key":"aaa","checkpoint":"2026-01-01T00:00:00+00:00","total_estimate":0}`) + syncB := []byte(`{"collection_key":"bbb","checkpoint":"2026-02-02T00:00:00+00:00","total_estimate":0}`) + if diffs := compareBodies(Response{Headers: jsonCT(), Body: Body(syncA)}, Response{Headers: jsonCT(), Body: Body(syncB)}, step); len(diffs) != 0 { + t.Fatalf("collection_key/checkpoint must mask: %+v", diffs) + } zdiffs := compareBodies(Response{Headers: jsonCT(), Body: Body(want)}, Response{Headers: jsonCT(), Body: Body(gotZ)}, step) if len(zdiffs) == 0 { t.Fatal("Z date must fail")