mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
Clean up conformance tar test data
This commit is contained in:
parent
442107b6b9
commit
995d408334
@ -41,7 +41,6 @@ go_test(
|
|||||||
"env_test.go",
|
"env_test.go",
|
||||||
"tar_test.go",
|
"tar_test.go",
|
||||||
],
|
],
|
||||||
data = glob(["testdata/**"]),
|
|
||||||
embed = [":go_default_library"],
|
embed = [":go_default_library"],
|
||||||
deps = ["//vendor/github.com/pkg/errors:go_default_library"],
|
deps = ["//vendor/github.com/pkg/errors:go_default_library"],
|
||||||
)
|
)
|
||||||
|
@ -32,6 +32,25 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestTar(t *testing.T) {
|
func TestTar(t *testing.T) {
|
||||||
|
tmp, err := ioutil.TempDir("", "testtar")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer os.Remove(tmp)
|
||||||
|
|
||||||
|
if err := os.Mkdir(filepath.Join(tmp, "subdir"), os.FileMode(0755)); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := ioutil.WriteFile(filepath.Join(tmp, "file1"), []byte(`file1 data`), os.FileMode(0644)); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := ioutil.WriteFile(filepath.Join(tmp, "file2"), []byte(`file2 data`), os.FileMode(0644)); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := ioutil.WriteFile(filepath.Join(tmp, "subdir", "file4"), []byte(`file4 data`), os.FileMode(0644)); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
desc string
|
desc string
|
||||||
dir string
|
dir string
|
||||||
@ -41,8 +60,8 @@ func TestTar(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
desc: "Contents preserved and no self-reference",
|
desc: "Contents preserved and no self-reference",
|
||||||
dir: "testdata/tartest",
|
dir: tmp,
|
||||||
outpath: "testdata/tartest/out.tar.gz",
|
outpath: filepath.Join(tmp, "out.tar.gz"),
|
||||||
expect: map[string]string{
|
expect: map[string]string{
|
||||||
"file1": "file1 data",
|
"file1": "file1 data",
|
||||||
"file2": "file2 data",
|
"file2": "file2 data",
|
||||||
@ -50,8 +69,8 @@ func TestTar(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
desc: "Errors if directory does not exist",
|
desc: "Errors if directory does not exist",
|
||||||
dir: "testdata/does-not-exist",
|
dir: filepath.Join(tmp, "does-not-exist"),
|
||||||
outpath: "testdata/tartest/out.tar.gz",
|
outpath: filepath.Join(tmp, "out.tar.gz"),
|
||||||
expectErr: "tar unable to stat directory",
|
expectErr: "tar unable to stat directory",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -1 +0,0 @@
|
|||||||
file1 data
|
|
@ -1 +0,0 @@
|
|||||||
file2 data
|
|
@ -1 +0,0 @@
|
|||||||
file4 data
|
|
Loading…
Reference in New Issue
Block a user