1
0
Fork 0
mirror of https://github.com/external-secrets/external-secrets.git synced 2024-12-14 11:57:59 +00:00

Merge pull request #241 from ElsaChelala/testcomparison

fix: test comparison
This commit is contained in:
paul-the-alien[bot] 2021-07-05 09:19:19 +00:00 committed by GitHub
commit c1639229f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 9 deletions

View file

@ -46,7 +46,7 @@ type secretsManagerTestCase struct {
expectError string
expectedSecret string
// for testing secretmap
expectedData map[string]string
expectedData map[string][]byte
}
func makeValidSecretsManagerTestCase() *secretsManagerTestCase {
@ -58,7 +58,7 @@ func makeValidSecretsManagerTestCase() *secretsManagerTestCase {
apiErr: nil,
expectError: "",
expectedSecret: "",
expectedData: map[string]string{},
expectedData: map[string][]byte{},
}
smtc.fakeClient.WithValue(smtc.apiInput, smtc.apiOutput, smtc.apiErr)
return &smtc
@ -191,7 +191,7 @@ func TestGetSecretMap(t *testing.T) {
// good case: default version & deserialization
setDeserialization := func(smtc *secretsManagerTestCase) {
smtc.apiOutput.SecretString = aws.String(`{"foo":"bar"}`)
smtc.expectedData["foo"] = "bar"
smtc.expectedData["foo"] = []byte("bar")
}
// bad case: invalid json
@ -213,7 +213,7 @@ func TestGetSecretMap(t *testing.T) {
if !ErrorContains(err, v.expectError) {
t.Errorf("[%d] unexpected error: %s, expected: '%s'", k, err.Error(), v.expectError)
}
if cmp.Equal(out, v.expectedData) {
if err == nil && !cmp.Equal(out, v.expectedData) {
t.Errorf("[%d] unexpected secret data: expected %#v, got %#v", k, v.expectedData, out)
}
}

View file

@ -16,10 +16,10 @@ package secretmanager
import (
"context"
"fmt"
"reflect"
"strings"
"testing"
"github.com/google/go-cmp/cmp"
secretmanagerpb "google.golang.org/genproto/googleapis/cloud/secretmanager/v1"
esv1alpha1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1alpha1"
@ -36,7 +36,7 @@ type secretManagerTestCase struct {
expectError string
expectedSecret string
// for testing secretmap
expectedData map[string]string
expectedData map[string][]byte
}
func makeValidSecretManagerTestCase() *secretManagerTestCase {
@ -49,7 +49,7 @@ func makeValidSecretManagerTestCase() *secretManagerTestCase {
apiErr: nil,
expectError: "",
expectedSecret: "",
expectedData: map[string]string{},
expectedData: map[string][]byte{},
}
smtc.mockClient.NilClose()
smtc.mockClient.WithValue(context.Background(), smtc.apiInput, smtc.apiOutput, smtc.apiErr)
@ -157,7 +157,7 @@ func TestGetSecretMap(t *testing.T) {
// good case: default version & deserialization
setDeserialization := func(smtc *secretManagerTestCase) {
smtc.apiOutput.Payload.Data = []byte(`{"foo":"bar"}`)
smtc.expectedData["foo"] = "bar"
smtc.expectedData["foo"] = []byte("bar")
}
// bad case: invalid json
@ -180,7 +180,7 @@ func TestGetSecretMap(t *testing.T) {
if !ErrorContains(err, v.expectError) {
t.Errorf("[%d] unexpected error: %s, expected: '%s'", k, err.Error(), v.expectError)
}
if cmp.Equal(out, v.expectedData) {
if err == nil && !reflect.DeepEqual(out, v.expectedData) {
t.Errorf("[%d] unexpected secret data: expected %#v, got %#v", k, v.expectedData, out)
}
}