@@ -14,7 +14,7 @@ import (
14
14
"github.com/google/go-cmp/cmp"
15
15
)
16
16
17
- func TestGetCrossref (t * testing.T ) {
17
+ func TestGet (t * testing.T ) {
18
18
t .Parallel ()
19
19
20
20
type testCase struct {
@@ -95,7 +95,7 @@ func TestFetch(t *testing.T) {
95
95
}
96
96
}
97
97
98
- func TestCrossrefQueryUrl (t * testing.T ) {
98
+ func TestQueryURL (t * testing.T ) {
99
99
t .Parallel ()
100
100
101
101
type testCase struct {
@@ -120,7 +120,14 @@ func TestCrossrefQueryUrl(t *testing.T) {
120
120
}
121
121
}
122
122
123
- func TestGetCrossrefList (t * testing.T ) {
123
+ func ExampleQueryURL () {
124
+ s := crossref .QueryURL (10 , "340" , "journal-article" , false , false , false , false , false , false , false , false , false )
125
+ println (s )
126
+ // Output:
127
+ // https://api.crossref.org/works?filter=member%3A340%2Ctype%3Ajournal-article&order=desc&rows=10&sort=published
128
+ }
129
+
130
+ func TestGetList (t * testing.T ) {
124
131
t .Parallel ()
125
132
126
133
type testCase struct {
@@ -138,14 +145,14 @@ func TestGetCrossrefList(t *testing.T) {
138
145
for _ , tc := range testCases {
139
146
got , err := crossref .GetList (tc .number , tc .member , tc ._type , true , false , false , false , false , false , false , false , false )
140
147
if err != nil {
141
- t .Errorf ("GetCrossrefSample (%v): error %v" , tc .number , err )
148
+ t .Errorf ("GetList (%v): error %v" , tc .number , err )
142
149
}
143
150
if diff := cmp .Diff (tc .number , len (got )); diff != "" {
144
- t .Errorf ("GetCrossrefList mismatch (-want +got):\n %s" , diff )
151
+ t .Errorf ("GetList mismatch (-want +got):\n %s" , diff )
145
152
}
146
153
}
147
154
}
148
- func TestGetCrossrefMember (t * testing.T ) {
155
+ func TestGetMember (t * testing.T ) {
149
156
t .Parallel ()
150
157
type testCase struct {
151
158
input string
@@ -164,3 +171,10 @@ func TestGetCrossrefMember(t *testing.T) {
164
171
}
165
172
}
166
173
}
174
+
175
+ func ExampleGetMember () {
176
+ s , _ := crossref .GetMember ("340" )
177
+ println (s )
178
+ // Output:
179
+ // Public Library of Science (PLoS)
180
+ }
0 commit comments