Skip to content

Commit

Permalink
Fixed dropper
Browse files Browse the repository at this point in the history
  • Loading branch information
KCarretto committed Feb 5, 2022
1 parent 584f69c commit dc7d4c7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/drop/drop.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TheBase(ctx context.Context, assets afero.Fs) {
DeleteUsingCWD()
DeleteUsingProc()

if err := afero.Walk(assets, "/scripts", func(path string, fi os.FileInfo, err error) error {
if err := afero.Walk(assets, "", func(path string, fi os.FileInfo, err error) error {
// Check for stat error
if err != nil {
fmt.Printf("[ERROR] failed to stat file %q: %s\n", path, err.Error())
Expand Down
22 changes: 17 additions & 5 deletions pkg/script/stdlib/assets/assets_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package assets_test

import (
"io/fs"
"io/ioutil"
"testing"

Expand All @@ -25,20 +26,20 @@ func writeFileForTest(fs afero.Fs, filename string, content string) error {
}

func TestTarGZBundleConsistent(t *testing.T) {
fs := afero.NewMemMapFs()
afs := afero.NewMemMapFs()
file1Name, file1Content := "file1", "boop"
file2Name, file2Content := "file2", "shmoop"

err := writeFileForTest(fs, file1Name, file1Content)
err := writeFileForTest(afs, file1Name, file1Content)
require.NoError(t, err, "failed to create test file")

err = writeFileForTest(fs, file2Name, file2Content)
err = writeFileForTest(afs, file2Name, file2Content)
require.NoError(t, err, "failed to create test file")

f1, err := fs.Open(file1Name)
f1, err := afs.Open(file1Name)
require.NoError(t, err, "failed to open file")

f2, err := fs.Open(file2Name)
f2, err := afs.Open(file2Name)
require.NoError(t, err, "failed to open file")

targzbundlr := assets.TarGZBundler{}
Expand Down Expand Up @@ -71,4 +72,15 @@ func TestTarGZBundleConsistent(t *testing.T) {

require.Equal(t, file1Content, string(newf1Content), "invalid file content")
require.Equal(t, file2Content, string(newf2Content), "invalid file content")

filenames := []string{}
afero.Walk(newFS, "", func(path string, info fs.FileInfo, err error) error {
require.NoError(t, err)
if !info.IsDir() {
filenames = append(filenames, path)
}
return nil
})

require.Len(t, filenames, 2)
}

0 comments on commit dc7d4c7

Please sign in to comment.