talos/internal/integration/cli/validate.go
Andrey Smirnov 96aa9638f7
chore: rename talos-systems/talos to siderolabs/talos
There's a cyclic dependency on siderolink library which imports talos
machinery back. We will fix that after we get talos pushed under a new
name.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
2022-11-03 16:50:32 +04:00

67 lines
1.5 KiB
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/.
//go:build integration_cli
package cli
import (
"fmt"
"os"
"github.com/siderolabs/talos/internal/integration/base"
)
// ValidateSuite verifies dmesg command.
type ValidateSuite struct {
base.CLISuite
tmpDir string
savedCwd string
}
// SuiteName ...
func (suite *ValidateSuite) SuiteName() string {
return "cli.ValidateSuite"
}
// SetupTest ...
func (suite *ValidateSuite) SetupTest() {
suite.tmpDir = suite.T().TempDir()
var err error
suite.savedCwd, err = os.Getwd()
suite.Require().NoError(err)
suite.Require().NoError(os.Chdir(suite.tmpDir))
}
// TearDownTest ...
func (suite *ValidateSuite) TearDownTest() {
if suite.savedCwd != "" {
suite.Require().NoError(os.Chdir(suite.savedCwd))
}
}
// TestValidate generates config and validates it for all the modes.
func (suite *ValidateSuite) TestValidate() {
suite.RunCLI([]string{"gen", "config", "foobar", "https://10.0.0.1"})
for _, configFile := range []string{"controlplane.yaml", "worker.yaml"} {
configFile := configFile
for _, mode := range []string{"cloud", "container"} {
mode := mode
suite.Run(fmt.Sprintf("%s-%s", configFile, mode), func() {
suite.RunCLI([]string{"validate", "-m", mode, "-c", configFile, "--strict"})
})
}
}
}
func init() {
allSuites = append(allSuites, new(ValidateSuite))
}