Merge pull request #2344 from coreos-inc/v1-search-fix

Implement the full spec for the old Docker V1 registry search API
This commit is contained in:
josephschorr 2017-02-16 15:08:33 -05:00 committed by GitHub
commit 38e079ced2
2 changed files with 59 additions and 14 deletions

View file

@ -1289,6 +1289,31 @@ class V1RegistryTests(V1RegistryPullMixin, V1RegistryPushMixin, RegistryTestsMix
self.assertEquals(1, len(data['results']))
def test_search_pagination(self):
# Check for the first page.
resp = self.conduct('GET', '/v1/search', params=dict(q='s', n='1'))
data = resp.json()
self.assertEquals('s', data['query'])
self.assertEquals(1, data['num_results'])
self.assertEquals(1, len(data['results']))
self.assertEquals(1, data['page'])
self.assertTrue(data['num_pages'] > 1)
# Check for the followup pages.
for page_index in range(1, data['num_pages']):
resp = self.conduct('GET', '/v1/search', params=dict(q='s', n='1', page=page_index))
data = resp.json()
self.assertEquals('s', data['query'])
self.assertEquals(1, data['num_results'])
self.assertEquals(1, len(data['results']))
self.assertEquals(1, data['page'])
self.assertTrue(data['num_pages'] > 1)
def test_users(self):
# Not logged in, should 404.
self.conduct('GET', '/v1/users', expected_code=404)