Add flag --build to wwctl container copy, default false
Signed-off-by: xu yang <xyang@ciq.com>
This commit is contained in:
committed by
Jonathon Anderson
parent
6796a69c3f
commit
1f492dfed5
33
internal/app/wwctl/container/copy/main_test.go
Normal file
33
internal/app/wwctl/container/copy/main_test.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package copy
|
||||
|
||||
import (
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/warewulf/warewulf/internal/pkg/testenv"
|
||||
"github.com/warewulf/warewulf/internal/pkg/warewulfd"
|
||||
)
|
||||
|
||||
func Test_Copy(t *testing.T) {
|
||||
env := testenv.New(t)
|
||||
env.WriteFile(t, path.Join(testenv.WWChrootdir, "test-container/rootfs/bin/sh"), `test`)
|
||||
defer env.RemoveAll(t)
|
||||
warewulfd.SetNoDaemon()
|
||||
|
||||
t.Run("container copy without build", func(t *testing.T) {
|
||||
baseCmd := GetCommand()
|
||||
baseCmd.SetArgs([]string{"test-container", "test-container-copy-without-build"})
|
||||
err := baseCmd.Execute()
|
||||
assert.NoError(t, err)
|
||||
assert.NoFileExists(t, path.Join(env.BaseDir, testenv.WWProvisiondir, "container", "test-container-copy-without-build.img"))
|
||||
})
|
||||
|
||||
t.Run("container copy with build", func(t *testing.T) {
|
||||
baseCmd := GetCommand()
|
||||
baseCmd.SetArgs([]string{"-b", "test-container", "test-container-copy"})
|
||||
err := baseCmd.Execute()
|
||||
assert.NoError(t, err)
|
||||
assert.FileExists(t, path.Join(env.BaseDir, testenv.WWProvisiondir, "container", "test-container-copy.img"))
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user