Skip to content

Commit

Permalink
fix: invalid zip file (#253)
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Alexandro Becker <[email protected]>
  • Loading branch information
caarlos0 authored Nov 10, 2020
1 parent 105a426 commit 7feb081
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions apk/apk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func TestDisableGlobbing(t *testing.T) {
info := exampleInfo()
info.DisableGlobbing = true
info.Files = map[string]string{
"../testdata/{file}*": "/test/{file}*",
"../testdata/{file}[": "/test/{file}[",
}

size := int64(0)
Expand All @@ -319,8 +319,8 @@ func TestDisableGlobbing(t *testing.T) {
dataTar, err := ioutil.ReadAll(gzr)
require.NoError(t, err)

extractedContent := extractFromTar(t, dataTar, "test/{file}*")
actualContent, err := ioutil.ReadFile("../testdata/{file}*")
extractedContent := extractFromTar(t, dataTar, "test/{file}[")
actualContent, err := ioutil.ReadFile("../testdata/{file}[")
require.NoError(t, err)
require.Equal(t, actualContent, extractedContent)
}
Expand Down
6 changes: 3 additions & 3 deletions deb/deb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -777,16 +777,16 @@ func TestDisableGlobbing(t *testing.T) {
info := exampleInfo()
info.DisableGlobbing = true
info.Files = map[string]string{
"../testdata/{file}*": "/test/{file}*",
"../testdata/{file}[": "/test/{file}[",
}

dataTarGz, _, _, err := createDataTarGz(info)
require.NoError(t, err)

expectedContent, err := ioutil.ReadFile("../testdata/{file}*")
expectedContent, err := ioutil.ReadFile("../testdata/{file}[")
require.NoError(t, err)

actualContent, err := extractFileFromTarGz(dataTarGz, "/test/{file}*")
actualContent, err := extractFileFromTarGz(dataTarGz, "/test/{file}[")
require.NoError(t, err)

assert.Equal(t, expectedContent, actualContent)
Expand Down
6 changes: 3 additions & 3 deletions internal/files/files_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ func TestListFilesToCopy(t *testing.T) {

func TestListFilesToCopyWithAndWithoutGlobbing(t *testing.T) {
_, err := Expand(map[string]string{
"../../testdata/{file}*": "/test/{file}*",
"../../testdata/{file}*": "/test/{file}[",
}, false)
assert.EqualError(t, err, "glob failed: ../../testdata/{file}*: no matching files")

files, err := Expand(map[string]string{
"../../testdata/{file}*": "/test/{file}*",
"../../testdata/{file}[": "/test/{file}[",
}, true)
require.NoError(t, err)
assert.Equal(t, []FileToCopy{
{"../../testdata/{file}*", "/test/{file}*"},
{"../../testdata/{file}[", "/test/{file}["},
}, files)
}
6 changes: 3 additions & 3 deletions rpm/rpm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -647,17 +647,17 @@ func TestDisableGlobbing(t *testing.T) {
info := exampleInfo()
info.DisableGlobbing = true
info.Files = map[string]string{
"../testdata/{file}*": "/test/{file}*",
"../testdata/{file}[": "/test/{file}[",
}

var rpmFileBuffer bytes.Buffer
err := Default.Package(info, &rpmFileBuffer)
require.NoError(t, err)

expectedContent, err := ioutil.ReadFile("../testdata/{file}*")
expectedContent, err := ioutil.ReadFile("../testdata/{file}[")
require.NoError(t, err)

actualContent, err := extractFileFromRpm(rpmFileBuffer.Bytes(), "/test/{file}*")
actualContent, err := extractFileFromRpm(rpmFileBuffer.Bytes(), "/test/{file}[")
require.NoError(t, err)

assert.Equal(t, expectedContent, actualContent)
Expand Down
File renamed without changes.

1 comment on commit 7feb081

@vercel
Copy link

@vercel vercel bot commented on 7feb081 Nov 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.