-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #382 from kairos-io/fix-uki-upgrade
Skip dirs in copyArtifactSetRole and replace only basename
- Loading branch information
Showing
3 changed files
with
95 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package uki | ||
|
||
import ( | ||
"bytes" | ||
"os" | ||
|
||
cnst "github.com/kairos-io/kairos-agent/v2/pkg/constants" | ||
fsutils "github.com/kairos-io/kairos-agent/v2/pkg/utils/fs" | ||
sdkTypes "github.com/kairos-io/kairos-sdk/types" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"github.com/twpayne/go-vfs/v4" | ||
"github.com/twpayne/go-vfs/v4/vfst" | ||
) | ||
|
||
var _ = Describe("Common functions tests", func() { | ||
Describe("copyArtifactSetRole", func() { | ||
var fs vfs.FS | ||
var err error | ||
var memLog *bytes.Buffer | ||
var logger sdkTypes.KairosLogger | ||
|
||
BeforeEach(func() { | ||
fs, _, err = vfst.NewTestFS(map[string]interface{}{}) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
logger = sdkTypes.NewBufferLogger(memLog) | ||
logger.SetLevel("debug") | ||
|
||
Expect(fsutils.MkdirAll(fs, "/active", cnst.DirPerm)).ToNot(HaveOccurred()) | ||
Expect(fsutils.MkdirAll(fs, "/other", cnst.DirPerm)).ToNot(HaveOccurred()) | ||
|
||
f, err := fs.Create("/other/active.efi") | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
_, err = os.Stat(f.Name()) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
f, err = fs.Create("/other/other.efi") | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
_, err = os.Stat(f.Name()) | ||
Expect(err).ToNot(HaveOccurred()) | ||
}) | ||
|
||
It("skips directories", func() { | ||
err = copyArtifactSetRole(fs, "/", "active", "passive", logger) | ||
Expect(err).ToNot(HaveOccurred()) | ||
}) | ||
|
||
It("replaces only the base file name", func() { | ||
err = copyArtifactSetRole(fs, "/other", "other", "newother", logger) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
glob, _ := fs.Glob("/other/*") | ||
Expect(glob).To(HaveExactElements([]string{ | ||
"/other/active.efi", | ||
"/other/newother.efi", | ||
"/other/other.efi", | ||
})) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package uki_test | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestActionSuite(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Uki test suite") | ||
} |