BREAKING: Return empty taglist for not-existing repository

parent 08eb1530
Pipeline #113358463 passed with stage
in 1 minute and 1 second
......@@ -178,6 +178,8 @@ func (c *Client) ListTags(ctx context.Context, image string) ([]string, error) {
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
switch resp.StatusCode {
case http.StatusNotFound:
return result, nil
case http.StatusForbidden:
return nil, ErrForbidden
case http.StatusUnauthorized:
......
......@@ -19,6 +19,34 @@ func TestMain(m *testing.M) {
os.Exit(m.Run())
}
func TestListTags(t *testing.T) {
if !integrating {
t.SkipNow()
}
reg := setupRegistry(t)
defer teardownRegistry(t, reg)
ctx := context.Background()
c := NewClient()
c.Scheme = "http"
c.Host = fmt.Sprintf("localhost:%s", reg.GetPort("5000/tcp"))
time.Sleep(time.Second * 1)
pullImage(t, reg, "hello-world:latest")
tagImage(t, reg, "hello-world:latest", localImage(t, reg, "hello-world:latest"))
pushImage(t, reg, localImage(t, reg, "hello-world:latest"))
result, err := c.ListTags(ctx, "hello-world")
require.NoError(t, err)
require.Equal(t, result, []string{"latest"})
// If we now request information about a repository, we should get an empty
// list:
result, err = c.ListTags(ctx, "not-there")
require.NoError(t, err)
require.Equal(t, result, []string{})
}
func TestListRepositories(t *testing.T) {
if !integrating {
t.SkipNow()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment