1// Copyright 2021 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package main
16
17import (
18	"reflect"
19	"testing"
20)
21
22func Test_combine(t *testing.T) {
23	tests := []struct {
24		name string
25		old  any
26		new  any
27		want any
28	}{
29		{
30			name: "objects",
31			old: map[string]any{
32				"foo": "bar",
33				"baz": []any{"a"},
34			},
35			new: map[string]any{
36				"foo": "bar",
37				"baz": []any{"b"},
38			},
39			want: map[string]any{
40				"foo": "bar",
41				"baz": []any{"a", "b"},
42			},
43		},
44		{
45			name: "arrays",
46			old:  []any{"foo", "bar"},
47			new:  []any{"foo", "baz"},
48			want: []any{"bar", "baz", "foo"},
49		},
50	}
51	for _, tt := range tests {
52		t.Run(tt.name, func(t *testing.T) {
53			if got := combine(tt.old, tt.new); !reflect.DeepEqual(got, tt.want) {
54				t.Errorf("combine() = %v, want %v", got, tt.want)
55			}
56		})
57	}
58}
59