diff --git a/archive_test.go b/archive_test.go index 7f4f07b..8588251 100644 --- a/archive_test.go +++ b/archive_test.go @@ -4,8 +4,11 @@ import ( "archive/zip" "fmt" "os" + "path/filepath" "slices" + "sort" "testing" + "time" "github.com/fujiwara/lambroll" @@ -115,3 +118,30 @@ func TestLoadNotZipArchive(t *testing.T) { } t.Log(err) } + +func TestUnzip(t *testing.T) { + dest := t.TempDir() + if err := lambroll.Unzip("test/src.zip", dest, false); err != nil { + t.Error("failed to Unzip", err) + } + unzipEntries := []string{} + err := filepath.WalkDir(dest, func(path string, d os.DirEntry, err error) error { + if err != nil { + return err + } + if d.IsDir() { + return nil + } + rel, _ := filepath.Rel(dest, path) + unzipEntries = append(unzipEntries, rel) + return nil + }) + if err != nil { + t.Error("failed to walk", err) + } + sort.Strings(unzipEntries) + expected := []string{"dir/sub.txt", "hello.txt", "world"} + if diff := cmp.Diff(unzipEntries, expected); diff != "" { + t.Errorf("unexpected unzip entries %s", diff) + } +} diff --git a/export_test.go b/export_test.go index 54a91c8..21a4b25 100644 --- a/export_test.go +++ b/export_test.go @@ -15,6 +15,7 @@ var ( MarshalJSON = marshalJSON NewFunctionFrom = newFunctionFrom NewCallerIdentity = newCallerIdentity + Unzip = unzip ) type VersionsOutput = versionsOutput