talos/internal/pkg/kernel/kernel_test.go
Andrey Smirnov 99b3c91ba7 test: add kernel pkg tests, improve parsing (#430)
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2019-02-28 13:06:30 -08:00

37 lines
1010 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 kernel_test
import (
"testing"
"github.com/stretchr/testify/suite"
"github.com/autonomy/talos/internal/pkg/kernel"
)
type KernelSuite struct {
suite.Suite
}
func (suite *KernelSuite) TestParseKernelBootParameters() {
for _, t := range []struct {
params []byte
expected map[string]string
}{
{[]byte(""), map[string]string{}},
{[]byte("boot=xyz root=/dev/abc nogui"), map[string]string{"boot": "xyz", "root": "/dev/abc", "nogui": ""}},
{[]byte(" root=/dev/abc=1 nogui \n"), map[string]string{"root": "/dev/abc=1", "nogui": ""}},
{[]byte("root=/dev/sda root=/dev/sdb"), map[string]string{"root": "/dev/sdb"}},
} {
suite.Assert().Equal(t.expected, kernel.ParseKernelBootParameters(t.params))
}
}
func TestKernelSuite(t *testing.T) {
suite.Run(t, new(KernelSuite))
}