diff options
Diffstat (limited to 'skate/zippy_test.go')
-rw-r--r-- | skate/zippy_test.go | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/skate/zippy_test.go b/skate/zippy_test.go index 1448472..7fd32ae 100644 --- a/skate/zippy_test.go +++ b/skate/zippy_test.go @@ -1,6 +1,11 @@ package skate -import "testing" +import ( + "reflect" + "testing" + + "github.com/kr/pretty" +) func TestLineColumn(t *testing.T) { var cases = []struct { @@ -23,3 +28,54 @@ func TestLineColumn(t *testing.T) { } } } + +func TestUniqueMatches(t *testing.T) { + var cases = []struct { + docs []string + result []*BiblioRef + err error + }{ + { + docs: []string{`{}`}, + result: []*BiblioRef{&BiblioRef{}}, + err: nil, + }, + { + docs: []string{`{ + "source_release_ident": "s1", + "target_release_ident": "t1"}`}, + result: []*BiblioRef{&BiblioRef{ + SourceReleaseIdent: "s1", + TargetReleaseIdent: "t1", + }}, + err: nil, + }, + { + docs: []string{` + {"source_release_ident": "s1", + "target_release_ident": "t1", + "match_status": "fuzzy"}`, + `{"source_release_ident": "s1", + "target_release_ident": "t1", + "match_status": "exact"}`, + }, + result: []*BiblioRef{&BiblioRef{ + SourceReleaseIdent: "s1", + TargetReleaseIdent: "t1", + MatchStatus: "exact", + }}, + err: nil, + }, + } + for _, c := range cases { + result, err := uniqueMatches(c.docs) + if err != c.err { + t.Fatalf("got %v, want %v", err, c.err) + } + if !reflect.DeepEqual(result, c.result) { + t.Fatalf("got %#v, want %#v", + pretty.Sprint(result), + pretty.Sprint(c.result)) + } + } +} |