Skip to content

Commit

Permalink
Fix unzip and add more unit tests. #16
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfireman committed Apr 19, 2018
1 parent f9932dd commit a6b1f88
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 0 additions & 1 deletion datapackage/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ func Load(path string, loaders ...validator.RegistryLoader) (*Package, error) {
if err != nil {
return nil, err
}
defer os.RemoveAll(dir)
fNames, err := unzip(path, dir)
if err != nil {
return nil, err
Expand Down
5 changes: 4 additions & 1 deletion datapackage/package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ func TestLoad(t *testing.T) {
// Writing a file which is in a subdir.
f1, err := w.Create("data/foo.csv")
is.NoErr(err)
_, err = f1.Write([]byte(`foo\nbar`))
_, err = f1.Write([]byte(`foo`))
is.NoErr(err)
is.NoErr(w.Close())

Expand All @@ -504,6 +504,9 @@ func TestLoad(t *testing.T) {
res := pkg.GetResource("res1")
is.Equal(res.name, "res1")
is.Equal(res.path, []string{"data/foo.csv"})
contents, err := res.ReadAll()
is.NoErr(err)
is.Equal(contents[0], []string{"foo"})
})
t.Run("Remote", func(t *testing.T) {
is := is.New(t)
Expand Down

0 comments on commit a6b1f88

Please sign in to comment.