2022-09-05 03:06:08 -04:00
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2022-03-22 11:03:15 -04:00
|
|
|
package resources
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2022-09-21 07:47:57 -04:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/kubernetes"
|
2022-03-22 11:03:15 -04:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestAutoscalerDeploymentMarshalUnmarshal(t *testing.T) {
|
|
|
|
require := require.New(t)
|
|
|
|
assert := assert.New(t)
|
|
|
|
|
2022-07-21 08:41:07 -04:00
|
|
|
autoscalerDepl := NewDefaultAutoscalerDeployment(nil, nil, nil, "")
|
2022-03-22 11:03:15 -04:00
|
|
|
|
|
|
|
data, err := autoscalerDepl.Marshal()
|
|
|
|
require.NoError(err)
|
|
|
|
|
|
|
|
t.Log(string(data))
|
|
|
|
|
2022-10-05 09:02:46 -04:00
|
|
|
var recreated AutoscalerDeployment
|
2022-08-29 08:30:20 -04:00
|
|
|
require.NoError(kubernetes.UnmarshalK8SResources(data, &recreated))
|
2022-03-22 11:03:15 -04:00
|
|
|
assert.Equal(autoscalerDepl, &recreated)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAutoscalerDeploymentWithCommandMarshalUnmarshal(t *testing.T) {
|
|
|
|
require := require.New(t)
|
|
|
|
assert := assert.New(t)
|
|
|
|
|
2022-07-21 08:41:07 -04:00
|
|
|
autoscalerDepl := NewDefaultAutoscalerDeployment(nil, nil, nil, "")
|
2022-03-22 11:03:15 -04:00
|
|
|
|
|
|
|
data, err := autoscalerDepl.Marshal()
|
|
|
|
require.NoError(err)
|
|
|
|
|
|
|
|
t.Log(string(data))
|
|
|
|
|
2022-10-05 09:02:46 -04:00
|
|
|
var recreated AutoscalerDeployment
|
2022-08-29 08:30:20 -04:00
|
|
|
require.NoError(kubernetes.UnmarshalK8SResources(data, &recreated))
|
2022-03-22 11:03:15 -04:00
|
|
|
assert.Equal(autoscalerDepl, &recreated)
|
|
|
|
}
|