aboutsummaryrefslogtreecommitdiffstats
path: root/skate
diff options
context:
space:
mode:
authorMartin Czygan <martin.czygan@gmail.com>2021-06-12 01:36:05 +0200
committerMartin Czygan <martin.czygan@gmail.com>2021-06-12 01:36:05 +0200
commit8b1bdd3e230bab7f1554b7fd019d64121ade6193 (patch)
tree645b267edc99a9ea905670eb490840f133b10eba /skate
parent18b938ff7aac1cef21de05ebd3671ab90b063c87 (diff)
downloadrefcat-8b1bdd3e230bab7f1554b7fd019d64121ade6193.tar.gz
refcat-8b1bdd3e230bab7f1554b7fd019d64121ade6193.zip
deduplication: tweak test
Diffstat (limited to 'skate')
-rw-r--r--skate/zippy.go2
-rw-r--r--skate/zippy_test.go43
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))
}
}
}