Skip to content

Commit

Permalink
Merge pull request #768 from jromero/chore/unfocus-tests
Browse files Browse the repository at this point in the history
Unfocus Access Checker Tests and update error messages to match
  • Loading branch information
matthewmcnew authored Jul 13, 2021
2 parents b54db48 + d8a48e9 commit 27ea452
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/dockercreds/access_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func testAccessChecker(t *testing.T, when spec.G, it spec.S) {
_ = VerifyWriteAccess(testKeychain{}, tagName)
})

it.Focus("errors when fetching token is unauthorized", func() {
it("errors when fetching token is unauthorized", func() {
handler.HandleFunc("/unauthorized-token/", func(writer http.ResponseWriter, request *http.Request) {
writer.WriteHeader(401)
writer.Write([]byte(`{"errors": [{"code": "UNAUTHORIZED"}]}`))
Expand Down Expand Up @@ -93,7 +93,7 @@ func testAccessChecker(t *testing.T, when spec.G, it spec.S) {
})

err := VerifyWriteAccess(testKeychain{}, tagName)
assert.EqualError(t, err, fmt.Sprintf("POST %s/v2/some/image/blobs/uploads/: unsupported status code 403", server.URL))
assert.EqualError(t, err, fmt.Sprintf("POST %s/v2/some/image/blobs/uploads/: unexpected status code 403 Forbidden", server.URL))
})

it("errors when cannot reach server", func() {
Expand All @@ -102,7 +102,7 @@ func testAccessChecker(t *testing.T, when spec.G, it spec.S) {
})

err := VerifyWriteAccess(testKeychain{}, tagName)
assert.EqualError(t, err, fmt.Sprintf("GET %s/v2/: unsupported status code 404", server.URL))
assert.EqualError(t, err, fmt.Sprintf("GET %s/v2/: unexpected status code 404 Not Found", server.URL))
})

it("errors when server errors", func() {
Expand All @@ -111,7 +111,7 @@ func testAccessChecker(t *testing.T, when spec.G, it spec.S) {
})

err := VerifyWriteAccess(testKeychain{}, tagName)
assert.EqualError(t, err, fmt.Sprintf("GET %s/v2/: unsupported status code 500", server.URL))
assert.EqualError(t, err, fmt.Sprintf("GET %s/v2/: unexpected status code 500 Internal Server Error", server.URL))
})
})

Expand Down Expand Up @@ -148,7 +148,7 @@ func testAccessChecker(t *testing.T, when spec.G, it spec.S) {
})

err := VerifyReadAccess(testKeychain{}, tagName)
assert.EqualError(t, err, fmt.Sprintf("GET %s/v2/: unsupported status code 404 Not Found", server.URL))
assert.EqualError(t, err, fmt.Sprintf("GET %s/v2/: unexpected status code 404 Not Found", server.URL))
})
})
}
Expand Down

0 comments on commit 27ea452

Please sign in to comment.