Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated cherry pick of #86232: Clean up conformance tar test data #94324

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion cluster/images/conformance/go-runner/BUILD
Expand Up @@ -41,7 +41,6 @@ go_test(
"env_test.go",
"tar_test.go",
],
data = glob(["testdata/**"]),
embed = [":go_default_library"],
deps = ["//vendor/github.com/pkg/errors:go_default_library"],
)
27 changes: 23 additions & 4 deletions cluster/images/conformance/go-runner/tar_test.go
Expand Up @@ -32,6 +32,25 @@ import (
)

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 {
desc string
dir string
Expand All @@ -41,17 +60,17 @@ func TestTar(t *testing.T) {
}{
{
desc: "Contents preserved and no self-reference",
dir: "testdata/tartest",
outpath: "testdata/tartest/out.tar.gz",
dir: tmp,
outpath: filepath.Join(tmp, "out.tar.gz"),
expect: map[string]string{
"file1": "file1 data",
"file2": "file2 data",
"subdir/file4": "file4 data",
},
}, {
desc: "Errors if directory does not exist",
dir: "testdata/does-not-exist",
outpath: "testdata/tartest/out.tar.gz",
dir: filepath.Join(tmp, "does-not-exist"),
outpath: filepath.Join(tmp, "out.tar.gz"),
expectErr: "tar unable to stat directory",
},
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.