diff options
Diffstat (limited to 'skate/schema_test.go')
-rw-r--r-- | skate/schema_test.go | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/skate/schema_test.go b/skate/schema_test.go index 1301184..a8f1ecf 100644 --- a/skate/schema_test.go +++ b/skate/schema_test.go @@ -256,6 +256,57 @@ func TestLinkHash(t *testing.T) { } } +func TestReleaseToUnstructured(t *testing.T) { + var cases = []struct { + r *Release + s string + }{ + {r: &Release{}, s: ""}, + {r: &Release{ + Title: "ABC", + }, s: "ABC"}, + {r: &Release{ + Title: "ABC", + ContainerName: "Journal of Letters", + }, s: "ABC. Journal of Letters"}, + {r: &Release{ + Title: "ABC", + ContainerName: "Journal of Letters", + Contribs: []struct { + Index int `json:"index,omitempty"` + RawName string `json:"raw_name,omitempty"` + Role string `json:"role,omitempty"` + }{ + { + RawName: "Liam Ling", + }, + }, + }, s: "Liam Ling. ABC. Journal of Letters"}, + {r: &Release{ + Title: "ABC", + ContainerName: "Journal of Letters", + Contribs: []struct { + Index int `json:"index,omitempty"` + RawName string `json:"raw_name,omitempty"` + Role string `json:"role,omitempty"` + }{ + { + RawName: "Liam Ling", + }, + { + RawName: "Lin Lee", + }, + }, + }, s: "Liam Ling, Lin Lee. ABC. Journal of Letters"}, + } + for _, c := range cases { + got := ReleaseToUnstructured(c.r) + if got != c.s { + t.Fatalf("got %v, want %v", got, c.s) + } + } +} + func BenchmarkParseIsbn(b *testing.B) { for n := 0; n < b.N; n++ { ParseIsbn("House Pvt. Limited., (2006), ISBN 9788183561426. Date accessed: August 2015.") |