From 6a151510dac7985a4825d5e05539063a2ce6a610 Mon Sep 17 00:00:00 2001 From: Martin Czygan Date: Tue, 15 Jun 2021 04:32:53 +0200 Subject: zippy: include raw ref when unmatched for debugging --- skate/schema.go | 3 +++ skate/zippy.go | 1 + skate/zippy_test.go | 17 +++++++++++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/skate/schema.go b/skate/schema.go index d36a771..7f707f3 100644 --- a/skate/schema.go +++ b/skate/schema.go @@ -345,6 +345,9 @@ type BiblioRef struct { MatchReason string `json:"match_reason,omitempty"` TargetUnstructured string `json:"target_unstructured,omitempty"` TargetCSL string `json:"target_csl,omitempty"` + Extra struct { + Ref Ref `json:"ref"` // keep the raw original ref around (e.g. for unmatched) + } `json:"extra"` } // ReleaseCluster, a list of match candidates. This is typically serialized as a diff --git a/skate/zippy.go b/skate/zippy.go index 2283733..69877b7 100644 --- a/skate/zippy.go +++ b/skate/zippy.go @@ -388,6 +388,7 @@ func matchedRefsExtend(matched []*BiblioRef, refs []*Ref, stats *statsAugment) [ // Reuse fields for debugging, for now. bref.MatchStatus = StatusUnmatched.Short() bref.MatchReason = ReasonUnknown.Short() + bref.Extra.Ref = *r matched = append(matched, &bref) } return matched diff --git a/skate/zippy_test.go b/skate/zippy_test.go index 16aa74d..817626b 100644 --- a/skate/zippy_test.go +++ b/skate/zippy_test.go @@ -193,6 +193,18 @@ func TestMatchedRefsExtend(t *testing.T) { MatchStatus: StatusUnmatched.Short(), MatchReason: ReasonUnknown.Short(), SourceYear: "0", + Extra: struct { + Ref Ref `json:"ref"` + }{ + Ref: Ref{ + ReleaseIdent: "0000", + Biblio: Biblio{ + Title: "Title", + }, + Index: 3, + Key: "K3", + }, + }, }, }, }, @@ -223,10 +235,11 @@ func TestMatchedRefsExtend(t *testing.T) { }, }, } - for _, c := range cases { + for i, c := range cases { result := matchedRefsExtend(c.matched, c.refs, &statsAugment{}) if !reflect.DeepEqual(result, c.result) { - t.Fatalf("got %v, want %v (%v)", result, c.result, pretty.Diff(result, c.result)) + t.Fatalf("[%d]: got %v, want %v (%v)", + i+1, result, c.result, pretty.Diff(result, c.result)) } } } -- cgit v1.2.3