ordermanager: fix test error introduced in #917 (#942)

* ordermanager: fix residual test issue from #917 and reduce some racey action

* glorious: nits; also removed functions that weren't being used and were unexported

* rm: pew

* linter: fix issues

* glourious: nits

* credentials: fix test issue with racey racey horse basey
This commit is contained in:
Ryan O'Hara-Reid
2022-05-11 14:18:21 +10:00
committed by GitHub
parent 61212fb8ea
commit 5cb26e7ecf
5 changed files with 189 additions and 280 deletions

View File

@@ -212,7 +212,6 @@ func TestAreCredentialsValid(t *testing.T) {
func TestValidateAPICredentials(t *testing.T) {
t.Parallel()
var b Base
type tester struct {
Key string
Secret string
@@ -247,7 +246,8 @@ func TestValidateAPICredentials(t *testing.T) {
{RequiresBase64DecodeSecret: true, Secret: "aGVsbG8gd29ybGQ="},
}
setupBase := func(b *Base, tData *tester) {
setupBase := func(tData *tester) *Base {
b := &Base{}
b.API.SetKey(tData.Key)
b.API.SetSecret(tData.Secret)
b.API.SetClientID(tData.ClientID)
@@ -257,13 +257,14 @@ func TestValidateAPICredentials(t *testing.T) {
b.API.CredentialsValidator.RequiresPEM = tData.RequiresPEM
b.API.CredentialsValidator.RequiresClientID = tData.RequiresClientID
b.API.CredentialsValidator.RequiresBase64DecodeSecret = tData.RequiresBase64DecodeSecret
return b
}
for x := range testCases {
testData := &testCases[x]
t.Run("", func(t *testing.T) {
t.Parallel()
setupBase(&b, testData)
b := setupBase(testData)
if err := b.ValidateAPICredentials(b.API.credentials); !errors.Is(err, testData.Expected) {
t.Errorf("Test %d: expected: %v: got %v", x+1, testData.Expected, err)
}