Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Run credentials tests in parallel
Browse files Browse the repository at this point in the history
A small change to use testing.T.Run for the credentials parsing test;
also removes a time.Sleep that according to git blame, I left in there
long ago.
  • Loading branch information
squaremo committed Jul 15, 2019
1 parent b0bf408 commit def50b6
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions registry/credentials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/base64"
"fmt"
"testing"
"time"

"github.com/stretchr/testify/assert"
)
Expand Down Expand Up @@ -88,19 +87,20 @@ func TestRemoteFactory_ParseHost(t *testing.T) {
error: true,
},
} {
stringCreds := fmt.Sprintf(tmpl, v.host, okCreds)
creds, err := ParseCredentials("test", []byte(stringCreds))
time.Sleep(100 * time.Millisecond)
if (err != nil) != v.error {
t.Fatalf("For test %q, expected error = %v but got %v", v.host, v.error, err != nil)
}
if v.error {
continue
}
actualUser := creds.credsFor(v.imagePrefix).username
assert.Equal(t, user, actualUser, "For test %q, expected %q but got %v", v.host, user, actualUser)
actualPass := creds.credsFor(v.imagePrefix).password
assert.Equal(t, pass, actualPass, "For test %q, expected %q but got %v", v.host, user, actualPass)
t.Run(v.host, func(t *testing.T) {
stringCreds := fmt.Sprintf(tmpl, v.host, okCreds)
creds, err := ParseCredentials("test", []byte(stringCreds))
if (err != nil) != v.error {
t.Fatalf("For test %q, expected error = %v but got %v", v.host, v.error, err != nil)
}
if v.error {
return
}
actualUser := creds.credsFor(v.imagePrefix).username
assert.Equal(t, user, actualUser, "For test %q, expected %q but got %v", v.host, user, actualUser)
actualPass := creds.credsFor(v.imagePrefix).password
assert.Equal(t, pass, actualPass, "For test %q, expected %q but got %v", v.host, user, actualPass)
})
}
}

Expand Down

0 comments on commit def50b6

Please sign in to comment.