aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Czygan <martin.czygan@gmail.com>2021-07-10 03:17:36 +0200
committerMartin Czygan <martin.czygan@gmail.com>2021-07-10 03:17:36 +0200
commitfa97e43b9b72ddcd2719afc41702642bbf64c59f (patch)
treeaa6a52037987723044b4ce2c2d6a96ab4cf1b58b
parent9f2c63a4e87a2638cc63620e6722fae494495dc6 (diff)
downloadrefcat-fa97e43b9b72ddcd2719afc41702642bbf64c59f.tar.gz
refcat-fa97e43b9b72ddcd2719afc41702642bbf64c59f.zip
schema: add test
-rw-r--r--skate/schema.go6
-rw-r--r--skate/schema_test.go14
2 files changed, 20 insertions, 0 deletions
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"},