68 lines
1.6 KiB
Go
68 lines
1.6 KiB
Go
/*
|
|
Copyright © 2022 - 2025 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 (
|
|
"os"
|
|
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
var _ = Describe("pull-image", Label("pull-image", "cmd", "root"), func() {
|
|
Describe("execution", func() {
|
|
BeforeEach(func() {
|
|
rootCmd = NewRootCmd()
|
|
_ = NewPullImageCmd(rootCmd, true)
|
|
})
|
|
AfterEach(func() {
|
|
viper.Reset()
|
|
})
|
|
It("executes command correctly", func() {
|
|
d, err := os.MkdirTemp("", "elemental")
|
|
Expect(err).ToNot(HaveOccurred())
|
|
defer os.RemoveAll(d)
|
|
|
|
_, _, err = executeCommandC(
|
|
rootCmd,
|
|
"pull-image",
|
|
"alpine",
|
|
d,
|
|
)
|
|
Expect(err).ToNot(HaveOccurred())
|
|
})
|
|
It("fails when image is missing", Label("args"), func() {
|
|
_, _, err := executeCommandC(
|
|
rootCmd,
|
|
"pull-image",
|
|
)
|
|
Expect(err).To(HaveOccurred())
|
|
})
|
|
It("fails when image is not an image", Label("args"), func() {
|
|
_, _, err := executeCommandC(
|
|
rootCmd,
|
|
"pull-image",
|
|
"fakeImage",
|
|
"fakeDest",
|
|
)
|
|
Expect(err).To(HaveOccurred())
|
|
})
|
|
|
|
})
|
|
})
|