2022-09-05 03:06:08 -04:00
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2022-08-29 08:30:20 -04:00
|
|
|
package kubernetes
|
2022-03-25 05:42:27 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
k8s "k8s.io/api/core/v1"
|
|
|
|
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestConfigMaps(t *testing.T) {
|
|
|
|
require := require.New(t)
|
|
|
|
assert := assert.New(t)
|
|
|
|
|
|
|
|
configMaps := ConfigMaps{
|
|
|
|
&k8s.ConfigMap{
|
|
|
|
TypeMeta: v1.TypeMeta{
|
|
|
|
Kind: "ConfigMap",
|
|
|
|
APIVersion: "v1",
|
|
|
|
},
|
|
|
|
Data: map[string]string{"key": "value1"},
|
|
|
|
},
|
|
|
|
&k8s.ConfigMap{
|
|
|
|
TypeMeta: v1.TypeMeta{
|
|
|
|
Kind: "ConfigMap",
|
|
|
|
APIVersion: "v1",
|
|
|
|
},
|
|
|
|
Data: map[string]string{"key": "value2"},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
data, err := configMaps.Marshal()
|
|
|
|
require.NoError(err)
|
|
|
|
|
|
|
|
assert.Equal(`apiVersion: v1
|
|
|
|
data:
|
|
|
|
key: value1
|
|
|
|
kind: ConfigMap
|
|
|
|
metadata:
|
|
|
|
creationTimestamp: null
|
|
|
|
---
|
|
|
|
apiVersion: v1
|
|
|
|
data:
|
|
|
|
key: value2
|
|
|
|
kind: ConfigMap
|
|
|
|
metadata:
|
|
|
|
creationTimestamp: null
|
|
|
|
`, string(data))
|
|
|
|
}
|