mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-09-25 13:33:41 +00:00
add tests
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
This commit is contained in:
@@ -17,16 +17,17 @@ package config_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/kairos-io/kairos-agent/v2/pkg/constants"
|
|
||||||
v1 "github.com/kairos-io/kairos-agent/v2/pkg/types/v1"
|
|
||||||
"github.com/kairos-io/kairos-agent/v2/pkg/utils/fs"
|
|
||||||
v1mocks "github.com/kairos-io/kairos-agent/v2/tests/mocks"
|
|
||||||
"github.com/twpayne/go-vfs"
|
|
||||||
"github.com/twpayne/go-vfs/vfst"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/kairos-io/kairos-agent/v2/pkg/constants"
|
||||||
|
v1 "github.com/kairos-io/kairos-agent/v2/pkg/types/v1"
|
||||||
|
fsutils "github.com/kairos-io/kairos-agent/v2/pkg/utils/fs"
|
||||||
|
v1mocks "github.com/kairos-io/kairos-agent/v2/tests/mocks"
|
||||||
|
"github.com/twpayne/go-vfs"
|
||||||
|
"github.com/twpayne/go-vfs/vfst"
|
||||||
|
|
||||||
. "github.com/kairos-io/kairos-agent/v2/pkg/config"
|
. "github.com/kairos-io/kairos-agent/v2/pkg/config"
|
||||||
. "github.com/kairos-io/kairos-sdk/schema"
|
. "github.com/kairos-io/kairos-sdk/schema"
|
||||||
. "github.com/onsi/ginkgo/v2"
|
. "github.com/onsi/ginkgo/v2"
|
||||||
@@ -173,6 +174,12 @@ var _ = Describe("Schema", func() {
|
|||||||
Expect(err).ShouldNot(HaveOccurred())
|
Expect(err).ShouldNot(HaveOccurred())
|
||||||
loadedInstallState, err := config.LoadInstallState()
|
loadedInstallState, err := config.LoadInstallState()
|
||||||
Expect(err).ShouldNot(HaveOccurred())
|
Expect(err).ShouldNot(HaveOccurred())
|
||||||
|
stat, err := fs.Stat(statePath)
|
||||||
|
Expect(err).To(BeNil())
|
||||||
|
Expect(int(stat.Mode().Perm())).To(Equal(constants.ConfigPerm))
|
||||||
|
stat, err = fs.Stat(recoveryPath)
|
||||||
|
Expect(err).To(BeNil())
|
||||||
|
Expect(int(stat.Mode().Perm())).To(Equal(constants.ConfigPerm))
|
||||||
|
|
||||||
Expect(*loadedInstallState).To(Equal(*installState))
|
Expect(*loadedInstallState).To(Equal(*installState))
|
||||||
})
|
})
|
||||||
|
@@ -869,9 +869,14 @@ var _ = Describe("Elemental", Label("elemental"), func() {
|
|||||||
|
|
||||||
err = e.CopyCloudConfig(cloudInit)
|
err = e.CopyCloudConfig(cloudInit)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
copiedFile, err := fs.ReadFile(fmt.Sprintf("%s/90_custom.yaml", cnst.OEMDir))
|
configFilePath := fmt.Sprintf("%s/90_custom.yaml", cnst.OEMDir)
|
||||||
|
copiedFile, err := fs.ReadFile(configFilePath)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
Expect(copiedFile).To(ContainSubstring(testString))
|
Expect(copiedFile).To(ContainSubstring(testString))
|
||||||
|
stat, err := fs.Stat(configFilePath)
|
||||||
|
Expect(err).To(BeNil())
|
||||||
|
Expect(int(stat.Mode().Perm())).To(Equal(cnst.ConfigPerm))
|
||||||
|
|
||||||
})
|
})
|
||||||
It("Doesnt do anything if the config file is not set", func() {
|
It("Doesnt do anything if the config file is not set", func() {
|
||||||
err := e.CopyCloudConfig([]string{})
|
err := e.CopyCloudConfig([]string{})
|
||||||
|
Reference in New Issue
Block a user