1
// This Source Code Form is subject to the terms of the Mozilla Public
2
// License, v. 2.0. If a copy of the MPL was not distributed with this
3
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
10
"github.com/stretchr/testify/assert"
12
clientconfig "github.com/siderolabs/talos/pkg/machinery/client/config"
15
func TestConfigMerge(t *testing.T) {
16
context1 := &clientconfig.Context{}
17
context2 := &clientconfig.Context{}
19
for _, tt := range []struct {
21
config *clientconfig.Config
22
configToMerge *clientconfig.Config
24
expectedContext string
25
expectedContexts map[string]*clientconfig.Context
29
config: &clientconfig.Config{},
30
configToMerge: &clientconfig.Config{
32
Contexts: map[string]*clientconfig.Context{
37
expectedContext: "foo",
38
expectedContexts: map[string]*clientconfig.Context{
44
config: &clientconfig.Config{
46
Contexts: map[string]*clientconfig.Context{
50
configToMerge: &clientconfig.Config{
52
Contexts: map[string]*clientconfig.Context{
57
expectedContext: "bar",
58
expectedContexts: map[string]*clientconfig.Context{
65
config: &clientconfig.Config{
67
Contexts: map[string]*clientconfig.Context{
71
configToMerge: &clientconfig.Config{
73
Contexts: map[string]*clientconfig.Context{
78
expectedContext: "bar-1",
79
expectedContexts: map[string]*clientconfig.Context{
85
t.Run(tt.name, func(t *testing.T) {
87
c.Merge(tt.configToMerge)
89
assert.Equal(t, tt.expectedContext, c.Context)
90
assert.Equal(t, tt.expectedContexts, c.Contexts)