mirror of
https://github.com/kairos-io/osbuilder.git
synced 2025-09-05 09:12:10 +00:00
Rework cmds so they are inline with cobra examples
Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
This commit is contained in:
70
tools-image/enki/cmd/build-iso_test.go
Normal file
70
tools-image/enki/cmd/build-iso_test.go
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
Copyright © 2022 SUSE LLC
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var _ = Describe("BuildISO", Label("iso", "cmd"), func() {
|
||||
var buf *bytes.Buffer
|
||||
BeforeEach(func() {
|
||||
buf = new(bytes.Buffer)
|
||||
rootCmd.SetOut(buf)
|
||||
rootCmd.SetErr(buf)
|
||||
})
|
||||
AfterEach(func() {
|
||||
viper.Reset()
|
||||
})
|
||||
It("Errors out if no rootfs sources are defined", Label("flags"), func() {
|
||||
_, _, err := executeCommandC(rootCmd, "build-iso")
|
||||
fmt.Println(buf)
|
||||
Expect(err).ToNot(BeNil())
|
||||
Expect(err.Error()).To(ContainSubstring("rootfs source image for building ISO was not provided"))
|
||||
})
|
||||
It("Errors out if rootfs is a non valid argument", Label("flags"), func() {
|
||||
_, _, err := executeCommandC(rootCmd, "build-iso", "/no/image/reference")
|
||||
Expect(err).ToNot(BeNil())
|
||||
Expect(err.Error()).To(ContainSubstring("invalid image reference"))
|
||||
})
|
||||
It("Errors out if overlay roofs path does not exist", Label("flags"), func() {
|
||||
_, _, err := executeCommandC(
|
||||
rootCmd, "build-iso", "system/cos", "--overlay-rootfs", "/nonexistingpath",
|
||||
)
|
||||
Expect(err).ToNot(BeNil())
|
||||
Expect(err.Error()).To(ContainSubstring("Invalid path"))
|
||||
})
|
||||
It("Errors out if overlay uefi path does not exist", Label("flags"), func() {
|
||||
_, _, err := executeCommandC(
|
||||
rootCmd, "build-iso", "someimage:latest", "--overlay-uefi", "/nonexistingpath",
|
||||
)
|
||||
Expect(err).ToNot(BeNil())
|
||||
Expect(err.Error()).To(ContainSubstring("Invalid path"))
|
||||
})
|
||||
It("Errors out if overlay iso path does not exist", Label("flags"), func() {
|
||||
_, _, err := executeCommandC(
|
||||
rootCmd, "build-iso", "some/image:latest", "--overlay-iso", "/nonexistingpath",
|
||||
)
|
||||
Expect(err).ToNot(BeNil())
|
||||
Expect(err.Error()).To(ContainSubstring("Invalid path"))
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user