constellation/internal/config/attestationversion_test.go
Otto Bittner 30f2b332b3
api: restructure api pkg (#1851)
* api: rename AttestationVersionRepo to Client
* api: move client into separate subpkg for
clearer import paths.
* api: rename configapi -> attestationconfig
* api: rename versionsapi -> versions
* api: rename sut to client
* api: split versionsapi client and make it public
* api: split versionapi fetcher and make it public
* config: move attestationversion type to config
* api: fix attestationconfig client test

Co-authored-by: Adrian Stobbe <stobbe.adrian@gmail.com>
2023-06-02 09:19:23 +02:00

47 lines
759 B
Go

/*
Copyright (c) Edgeless Systems GmbH
SPDX-License-Identifier: AGPL-3.0-only
*/
package config
import (
"testing"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v3"
)
func TestVersionMarshalYAML(t *testing.T) {
tests := []struct {
name string
sut AttestationVersion
want string
}{
{
name: "isLatest resolves to latest",
sut: AttestationVersion{
Value: 1,
IsLatest: true,
},
want: "latest\n",
},
{
name: "value 5 resolves to 5",
sut: AttestationVersion{
Value: 5,
IsLatest: false,
},
want: "5\n",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
bt, err := yaml.Marshal(tt.sut)
require.NoError(t, err)
require.Equal(t, tt.want, string(bt))
})
}
}