From fa97e43b9b72ddcd2719afc41702642bbf64c59f Mon Sep 17 00:00:00 2001 From: Martin Czygan Date: Sat, 10 Jul 2021 03:17:36 +0200 Subject: schema: add test --- skate/schema.go | 6 ++++++ skate/schema_test.go | 14 ++++++++++++++ 2 files changed, 20 insertions(+) (limited to 'skate') diff --git a/skate/schema.go b/skate/schema.go index 77460d1..23a54b9 100644 --- a/skate/schema.go +++ b/skate/schema.go @@ -180,6 +180,12 @@ func ReleaseToUnstructured(r *Release) string { } fmt.Fprintf(&buf, `%s`, r.Publisher) } + if r.ExtIDs.DOI != "" { + if buf.Len() > 0 { + fmt.Fprintf(&buf, ", ") + } + fmt.Fprintf(&buf, `%s`, r.ExtIDs.DOI) + } return buf.String() } diff --git a/skate/schema_test.go b/skate/schema_test.go index cfffced..cb1cf83 100644 --- a/skate/schema_test.go +++ b/skate/schema_test.go @@ -267,6 +267,20 @@ func TestReleaseToUnstructured(t *testing.T) { {r: &Release{Volume: "12", Issue: "X", ReleaseYearValue: "1999"}, s: "vol. 12, no. X, 1999"}, {r: &Release{Volume: "12", ContainerName: "Solar", ReleaseYearValue: "1999"}, s: "Solar, vol. 12, 1999"}, + {r: &Release{ExtIDs: struct { + Arxiv string `json:"arxiv,omitempty"` + Core string `json:"core,omitempty"` + DOI string `json:"doi,omitempty"` + ISBN []string `json:"isbn,omitempty"` // should be isbn13 + Jstor string `json:"jstor,omitempty"` + OLID string `json:"olid,omitempty"` + PMCID string `json:"pmcid,omitempty"` + PMID string `json:"pmid,omitempty"` + WikidataQID string `json:"wikidata_qid,omitempty"` + }{ + DOI: "10.1234/1234", + }, Volume: "12", ContainerName: "Solar", + ReleaseYearValue: "1999"}, s: "Solar, vol. 12, 1999, 10.1234/1234"}, {r: &Release{ Title: "ABC", }, s: "ABC"}, -- cgit v1.2.3