registry/handlers: use consistent names for test-tables

Also marked assertBlobUploadStateEquals as t.Helper()

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-04-30 15:21:48 +02:00
parent f4acd98865
commit 85028a801b
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -45,8 +45,8 @@ var secrets = []string{
func TestLayerUploadTokens(t *testing.T) { func TestLayerUploadTokens(t *testing.T) {
secret := hmacKey("supersecret") secret := hmacKey("supersecret")
for _, testcase := range blobUploadStates { for _, tc := range blobUploadStates {
token, err := secret.packUploadState(testcase) token, err := secret.packUploadState(tc)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -56,7 +56,7 @@ func TestLayerUploadTokens(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
assertBlobUploadStateEquals(t, testcase, lus) assertBlobUploadStateEquals(t, tc, lus)
} }
} }
@ -68,8 +68,8 @@ func TestHMACValidation(t *testing.T) {
secret2 := hmacKey(secret) secret2 := hmacKey(secret)
badSecret := hmacKey("DifferentSecret") badSecret := hmacKey("DifferentSecret")
for _, testcase := range blobUploadStates { for _, tc := range blobUploadStates {
token, err := secret1.packUploadState(testcase) token, err := secret1.packUploadState(tc)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -79,7 +79,7 @@ func TestHMACValidation(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
assertBlobUploadStateEquals(t, testcase, lus) assertBlobUploadStateEquals(t, tc, lus)
_, err = badSecret.unpackUploadState(token) _, err = badSecret.unpackUploadState(token)
if err == nil { if err == nil {
@ -105,6 +105,7 @@ func TestHMACValidation(t *testing.T) {
} }
func assertBlobUploadStateEquals(t *testing.T, expected blobUploadState, received blobUploadState) { func assertBlobUploadStateEquals(t *testing.T, expected blobUploadState, received blobUploadState) {
t.Helper()
if expected.Name != received.Name { if expected.Name != received.Name {
t.Fatalf("Expected Name=%q, Received Name=%q", expected.Name, received.Name) t.Fatalf("Expected Name=%q, Received Name=%q", expected.Name, received.Name)
} }