diff options
author | Martin Czygan <martin.czygan@gmail.com> | 2021-06-10 16:59:46 +0200 |
---|---|---|
committer | Martin Czygan <martin.czygan@gmail.com> | 2021-06-10 16:59:46 +0200 |
commit | e4b17b4bd3e68305d95776ae0273316c75e37eba (patch) | |
tree | b0f94d86143aaa385ecec534f278b1663d58e7e8 /skate | |
parent | c1cf9fed6be68c47331add945afe1d7e2c77428d (diff) | |
download | refcat-e4b17b4bd3e68305d95776ae0273316c75e37eba.tar.gz refcat-e4b17b4bd3e68305d95776ae0273316c75e37eba.zip |
add another case
Diffstat (limited to 'skate')
-rw-r--r-- | skate/zippy.go | 6 | ||||
-rw-r--r-- | skate/zippy_test.go | 20 |
2 files changed, 25 insertions, 1 deletions
diff --git a/skate/zippy.go b/skate/zippy.go index 1dbf6aa..c949069 100644 --- a/skate/zippy.go +++ b/skate/zippy.go @@ -327,10 +327,14 @@ func ZippyBrefAugment(bref, raw io.Reader, w io.Writer) error { // First, iterate over all matches and sort out duplicates, e.g. // docs that have the same source and target id. - _, err := uniqueMatches(g.G0) + unique, err := uniqueMatches(g.G0) if err != nil { return err } + // We want to find all items in g.G1, which are not in unique. This + // is a set like operation, but we want a custom comparator. + log.Println(unique) + return nil } ) diff --git a/skate/zippy_test.go b/skate/zippy_test.go index d51a459..84c878f 100644 --- a/skate/zippy_test.go +++ b/skate/zippy_test.go @@ -70,6 +70,26 @@ func TestUniqueMatches(t *testing.T) { }}, err: nil, }, + { + about: "if both are exact, we just take (any) one", + docs: []string{` + {"source_release_ident": "s1", + "target_release_ident": "t1", + "match_status": "exact", + "match_reason": "a"}`, + `{"source_release_ident": "s1", + "target_release_ident": "t1", + "match_status": "exact", + "match_reason": "b"}`, + }, + result: []*BiblioRef{&BiblioRef{ + SourceReleaseIdent: "s1", + TargetReleaseIdent: "t1", + MatchStatus: "exact", + MatchReason: "b", + }}, + err: nil, + }, } for _, c := range cases { result, err := uniqueMatches(c.docs) |