constellation/cli/internal/clusterid/id_test.go
Moritz Sanft 5f71934f56
cli: write Terraform migration output directly to constellation-id.json (#2107)
* backup `constellation-id.json` before upgrade

* remove superfluous `file.Handler` arguments

* merge `constellation-id.json` on upgrade

* fix typo
2023-07-18 09:33:42 +02:00

64 lines
964 B
Go

/*
Copyright (c) Edgeless Systems GmbH
SPDX-License-Identifier: AGPL-3.0-only
*/
package clusterid
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestMerge(t *testing.T) {
testCases := map[string]struct {
current File
other File
want File
}{
"empty": {
current: File{},
other: File{},
want: File{},
},
"current empty": {
current: File{},
other: File{
ClusterID: "clusterID",
},
want: File{
ClusterID: "clusterID",
},
},
"other empty": {
current: File{
ClusterID: "clusterID",
},
other: File{},
want: File{
ClusterID: "clusterID",
},
},
"both set": {
current: File{
ClusterID: "clusterID",
},
other: File{
ClusterID: "otherClusterID",
},
want: File{
ClusterID: "otherClusterID",
},
},
}
for _, tc := range testCases {
require := require.New(t)
ret := tc.current.Merge(tc.other)
require.Equal(tc.want, *ret)
}
}