talos/cmd/installer/pkg/install/meta_value_test.go
Andrey Smirnov 35d6adcb9a
fix: provide stashed META values before installation
Previously, if META values were supplied to the Talos ISO via
environment variable, they will be written down and available after the
install. With this fix, values are also readable and available before
the installation runs (in maintenance mode).

Most of the PR is refactoring `meta.Value(s)` to be a shared library
which is used by the installer/imager and (now) Talos.

Also fixes an issue with not returning properly `NotExist` error when
META is not yet available as a partition on disk.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
2023-06-27 20:57:43 +04:00

33 lines
728 B
Go

// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package install_test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/siderolabs/talos/cmd/installer/pkg/install"
)
func TestMetaValues(t *testing.T) {
t.Parallel()
var s install.MetaValues
require.NoError(t, s.Set("10=foo"))
require.NoError(t, s.Append("20=bar"))
assert.Equal(t, "[0xa=foo,0x14=bar]", s.String())
encoded := s.Encode()
var s2 install.MetaValues
require.NoError(t, s2.Decode(encoded))
assert.Equal(t, s.String(), s2.String())
}