func TestResolvePolicyNo3(t *testing.T) {
	const (
		configName, secretName = "all-cfg-map-test-redis", "all-secret-test-redis"
		keyNo1, keyNo2, keyNo3 = "keyNo1", "keyNo2", "keyNo3"
		namespace              = "test-ns"
	)
	ts := newResolverTestSuit()
	var (
		configData = configMapData{keyNo1: "key_1_cfg_val", keyNo2: "key_2_cfg_val"}
		secretData = secretData{keyNo1: []byte("key_1_secret_val"), keyNo3: []byte("key_3_secret_val")}
		bindYAML   = dedent.Dedent(`
          credential:
            - name: ` + keyNo1 + `
              value: override-value
          credentialFrom:
            - configMapRef:
                name: ` + configName + `
            - secretRef:
                name: ` + secretName)
		credentials = internal.InstanceCredentials{
			keyNo1: "override-value",
			keyNo2: "key_2_cfg_val",
			keyNo3: "key_3_secret_val",
		}
		configMap  = ts.configMap(namespace, "all-cfg-map-test-redis", configData)
		secret     = ts.secret(namespace, "all-secret-test-redis", secretData)
		fakeClient = fake.NewSimpleClientset(&configMap, &secret)
		resolver   = bind.NewResolver(fakeClient.CoreV1())
	)
	out, err := resolver.Resolve(bind.RenderedBindYAML(bindYAML), internal.Namespace(namespace))
	require.NoError(t, err)
	assert.EqualValues(t, credentials, out.Credentials)
	assert.Len(t, fakeClient.Actions(), 2)
}
Policy #3: Values defined by `credentialFrom` section will be overridden by values from `credential` section if keys will be duplicated
package bind_test
import (
	"fmt"
	"testing"
	"github.com/kyma-project/helm-broker/internal"
	"github.com/kyma-project/helm-broker/internal/bind"
	"github.com/lithammer/dedent"
	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
	v1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/client-go/kubernetes/fake"
)
func TestResolvePolicyNo1(t *testing.T) {
	const (
		configName, secretName = "all-cfg-map-test-redis", "all-secret-test-redis"
		keyNo1, keyNo2, keyNo3 = "keyNo1", "keyNo2", "keyNo3"
		namespace              = "test-ns"
	)
	type given struct {
		configData configMapData
		secretData secretData
		bindYAML   string
	}
	type expected struct {
		credentials internal.InstanceCredentials
	}
	for tn, tc := range map[string]struct {
		given
		expected
	}{
		"secret overrides configMap values": {
			given: given{
				configData: configMapData{keyNo1: "key_1_cfg_val", keyNo2: "key_2_cfg_val"},
				secretData: secretData{keyNo1: []byte("key_1_secret_val"), keyNo3: []byte("key_3_secret_val")},
				bindYAML: dedent.Dedent(`
                      credentialFrom:
                        - configMapRef:
                           name: ` + configName + `
                        - secretRef:
                           name: ` + secretName),
			},
			expected: expected{
				credentials: internal.InstanceCredentials{
					keyNo1: "key_1_secret_val",
					keyNo2: "key_2_cfg_val",
					keyNo3: "key_3_secret_val",
				},
			},
		},
		"configMap overrides secret values": {
			given: given{
				configData: configMapData{keyNo1: "key_1_cfg_val", keyNo2: "key_2_cfg_val"},
				secretData: secretData{keyNo1: []byte("key_1_secret_val"), keyNo3: []byte("key_3_secret_val")},
				bindYAML: dedent.Dedent(`
		             credentialFrom:
		               - secretRef:
		                   name: ` + secretName + `
		               - configMapRef:
		                  name: ` + configName),
			},
			expected: expected{
				credentials: internal.InstanceCredentials{
					keyNo1: "key_1_cfg_val",
					keyNo2: "key_2_cfg_val",
					keyNo3: "key_3_secret_val",
				},
			},
		},
	} {
		t.Run(tn, func(t *testing.T) {
			ts := newResolverTestSuit()
			var (
				configMap  = ts.configMap(namespace, "all-cfg-map-test-redis", tc.given.configData)
				secret     = ts.secret(namespace, "all-secret-test-redis", tc.given.secretData)
				fakeClient = fake.NewSimpleClientset(&configMap, &secret)
				resolver   = bind.NewResolver(fakeClient.CoreV1())
			)
			out, err := resolver.Resolve(bind.RenderedBindYAML(tc.given.bindYAML), internal.Namespace(namespace))
			require.NoError(t, err)
			assert.EqualValues(t, tc.expected.credentials, out.Credentials)
			assert.Len(t, fakeClient.Actions(), 2)
		})
	}
}
func TestResolvePolicyNo2(t *testing.T) {
	const (
		keyNo1    = "keyNo1"
		namespace = "test-ns"
	)
	bindYAML := dedent.Dedent(`
       credential:
        - name: ` + keyNo1 + `
          value: duplicated-value
        - name: ` + keyNo1 + `
          value: duplicated-value`)
	resolver := bind.NewResolver(nil)
	out, err := resolver.Resolve(bind.RenderedBindYAML(bindYAML), internal.Namespace(namespace))
	assert.EqualError(t, err, fmt.Sprintf("conflict: found credentials with the same name %q", keyNo1))
	assert.Nil(t, out)
}