From 8b1bdd3e230bab7f1554b7fd019d64121ade6193 Mon Sep 17 00:00:00 2001 From: Martin Czygan Date: Sat, 12 Jun 2021 01:36:05 +0200 Subject: deduplication: tweak test --- skate/zippy.go | 2 +- skate/zippy_test.go | 43 +++++++++++++++++++++++++++++++++++-------- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/skate/zippy.go b/skate/zippy.go index 152e93f..e169af2 100644 --- a/skate/zippy.go +++ b/skate/zippy.go @@ -362,7 +362,7 @@ func ZippyBrefAugment(bref, raw io.Reader, w io.Writer) error { func matchedRefsExtend(matched []*BiblioRef, refs []*Ref) []*BiblioRef { s := set.New() // store key + index of matched items for _, m := range matched { - s.Add(m.Key + fmt.Sprintf("%d", m.RefIndex)) + s.Add(m.RefKey + fmt.Sprintf("%d", m.RefIndex)) } for _, r := range refs { if s.Contains(r.Key + fmt.Sprintf("%d", r.Index)) { diff --git a/skate/zippy_test.go b/skate/zippy_test.go index 746bca4..ed982b7 100644 --- a/skate/zippy_test.go +++ b/skate/zippy_test.go @@ -140,6 +140,7 @@ func TestMatchedRefsExtend(t *testing.T) { }, refs: []*Ref{ &Ref{ + ReleaseIdent: "0000", Biblio: Biblio{ Title: "Title", }, @@ -154,12 +155,39 @@ func TestMatchedRefsExtend(t *testing.T) { RefKey: "K2", }, &BiblioRef{ - Key: "_3", - RefIndex: 3, - RefKey: "K3", - MatchStatus: StatusUnmatched.Short(), - MatchReason: ReasonUnknown.Short(), - SourceYear: "0", + Key: "0000_3", + SourceReleaseIdent: "0000", + RefIndex: 3, + RefKey: "K3", + MatchStatus: StatusUnmatched.Short(), + MatchReason: ReasonUnknown.Short(), + SourceYear: "0", + }, + }, + }, + { + matched: []*BiblioRef{ + &BiblioRef{ + SourceReleaseIdent: "pud5shsflfgrth77lmlernavjm", + RefIndex: 2, + RefKey: "K2", + }, + }, + refs: []*Ref{ + &Ref{ + ReleaseIdent: "0000", + Biblio: Biblio{ + Title: "Title", + }, + Index: 2, + Key: "K2", + }, + }, + result: []*BiblioRef{ + &BiblioRef{ + SourceReleaseIdent: "pud5shsflfgrth77lmlernavjm", + RefIndex: 2, + RefKey: "K2", }, }, }, @@ -167,8 +195,7 @@ func TestMatchedRefsExtend(t *testing.T) { for _, c := range cases { result := matchedRefsExtend(c.matched, c.refs) if !reflect.DeepEqual(result, c.result) { - t.Logf("got %v", pretty.Diff(result, c.result)) - t.Fatalf("got %v, want %v", result, c.result) + t.Fatalf("got %v, want %v (%v)", result, c.result, pretty.Diff(result, c.result)) } } } -- cgit v1.2.3