2022-10-24 06:23:18 -04:00
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
|
|
|
package helm
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestMe(t *testing.T) {
|
|
|
|
testCases := map[string]struct {
|
2022-10-25 09:51:23 -04:00
|
|
|
vals map[string]any
|
|
|
|
extraVals map[string]any
|
|
|
|
expected map[string]any
|
2022-10-24 06:23:18 -04:00
|
|
|
}{
|
|
|
|
"equal": {
|
2022-10-25 09:51:23 -04:00
|
|
|
vals: map[string]any{
|
|
|
|
"join-service": map[string]any{
|
2022-10-24 06:23:18 -04:00
|
|
|
"key1": "foo",
|
|
|
|
"key2": "bar",
|
|
|
|
},
|
|
|
|
},
|
2022-10-25 09:51:23 -04:00
|
|
|
extraVals: map[string]any{
|
|
|
|
"join-service": map[string]any{
|
2022-10-24 06:23:18 -04:00
|
|
|
"extraKey1": "extraFoo",
|
|
|
|
"extraKey2": "extraBar",
|
|
|
|
},
|
|
|
|
},
|
2022-10-25 09:51:23 -04:00
|
|
|
expected: map[string]any{
|
|
|
|
"join-service": map[string]any{
|
2022-10-24 06:23:18 -04:00
|
|
|
"key1": "foo",
|
|
|
|
"key2": "bar",
|
|
|
|
"extraKey1": "extraFoo",
|
|
|
|
"extraKey2": "extraBar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"missing join-service extraVals": {
|
2022-10-25 09:51:23 -04:00
|
|
|
vals: map[string]any{
|
|
|
|
"join-service": map[string]any{
|
2022-10-24 06:23:18 -04:00
|
|
|
"key1": "foo",
|
|
|
|
"key2": "bar",
|
|
|
|
},
|
|
|
|
},
|
2022-10-25 09:51:23 -04:00
|
|
|
extraVals: map[string]any{
|
2022-10-24 06:23:18 -04:00
|
|
|
"extraKey1": "extraFoo",
|
|
|
|
"extraKey2": "extraBar",
|
|
|
|
},
|
2022-10-25 09:51:23 -04:00
|
|
|
expected: map[string]any{
|
|
|
|
"join-service": map[string]any{
|
2022-10-24 06:23:18 -04:00
|
|
|
"key1": "foo",
|
|
|
|
"key2": "bar",
|
|
|
|
},
|
|
|
|
"extraKey1": "extraFoo",
|
|
|
|
"extraKey2": "extraBar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"missing join-service vals": {
|
2022-10-25 09:51:23 -04:00
|
|
|
vals: map[string]any{
|
2022-10-24 06:23:18 -04:00
|
|
|
"key1": "foo",
|
|
|
|
"key2": "bar",
|
|
|
|
},
|
2022-10-25 09:51:23 -04:00
|
|
|
extraVals: map[string]any{
|
|
|
|
"join-service": map[string]any{
|
2022-10-24 06:23:18 -04:00
|
|
|
"extraKey1": "extraFoo",
|
|
|
|
"extraKey2": "extraBar",
|
|
|
|
},
|
|
|
|
},
|
2022-10-25 09:51:23 -04:00
|
|
|
expected: map[string]any{
|
2022-10-24 06:23:18 -04:00
|
|
|
"key1": "foo",
|
|
|
|
"key2": "bar",
|
2022-10-25 09:51:23 -04:00
|
|
|
"join-service": map[string]any{
|
2022-10-24 06:23:18 -04:00
|
|
|
"extraKey1": "extraFoo",
|
|
|
|
"extraKey2": "extraBar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for name, tc := range testCases {
|
|
|
|
t.Run(name, func(t *testing.T) {
|
|
|
|
assert := assert.New(t)
|
|
|
|
newVals := mergeMaps(tc.vals, tc.extraVals)
|
|
|
|
assert.Equal(tc.expected, newVals)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|