Docker-DCO-1.1-Signed-off-by: Victor Vieux <victor.vieux@docker.com> (github: vieux)
Victor Vieux authored on 2014/03/14 02:40:34... | ... |
@@ -600,7 +600,7 @@ func (r *Registry) PushImageJSONIndex(remote string, imgList []*ImgData, validat |
600 | 600 |
|
601 | 601 |
func (r *Registry) SearchRepositories(term string) (*SearchResults, error) { |
602 | 602 |
utils.Debugf("Index server: %s", r.indexEndpoint) |
603 |
- u := IndexServerAddress() + "search?q=" + url.QueryEscape(term) |
|
603 |
+ u := r.indexEndpoint + "search?q=" + url.QueryEscape(term) |
|
604 | 604 |
req, err := r.reqFactory.NewRequest("GET", u, nil) |
605 | 605 |
if err != nil { |
606 | 606 |
return nil, err |
... | ... |
@@ -321,7 +321,12 @@ func handlerAuth(w http.ResponseWriter, r *http.Request) { |
321 | 321 |
} |
322 | 322 |
|
323 | 323 |
func handlerSearch(w http.ResponseWriter, r *http.Request) { |
324 |
- writeResponse(w, "{}", 200) |
|
324 |
+ result := &SearchResults{ |
|
325 |
+ Query: "fakequery", |
|
326 |
+ NumResults: 1, |
|
327 |
+ Results: []SearchResult{{Name: "fakeimage", StarCount: 42}}, |
|
328 |
+ } |
|
329 |
+ writeResponse(w, result, 200) |
|
325 | 330 |
} |
326 | 331 |
|
327 | 332 |
func TestPing(t *testing.T) { |
... | ... |
@@ -186,14 +186,16 @@ func TestPushImageJSONIndex(t *testing.T) { |
186 | 186 |
|
187 | 187 |
func TestSearchRepositories(t *testing.T) { |
188 | 188 |
r := spawnTestRegistry(t) |
189 |
- results, err := r.SearchRepositories("supercalifragilisticepsialidocious") |
|
189 |
+ results, err := r.SearchRepositories("fakequery") |
|
190 | 190 |
if err != nil { |
191 | 191 |
t.Fatal(err) |
192 | 192 |
} |
193 | 193 |
if results == nil { |
194 | 194 |
t.Fatal("Expected non-nil SearchResults object") |
195 | 195 |
} |
196 |
- assertEqual(t, results.NumResults, 0, "Expected 0 search results") |
|
196 |
+ assertEqual(t, results.NumResults, 1, "Expected 1 search results") |
|
197 |
+ assertEqual(t, results.Query, "fakequery", "Expected 'fakequery' as query") |
|
198 |
+ assertEqual(t, results.Results[0].StarCount, 42, "Expected 'fakeimage' a ot hae 42 stars") |
|
197 | 199 |
} |
198 | 200 |
|
199 | 201 |
func TestValidRepositoryName(t *testing.T) { |