-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for writing text files in Vacation
Signed-off-by: Timothy Hitchener <thitchener@pivotal.io>
- Loading branch information
1 parent
b3dad1d
commit cb4becf
Showing
5 changed files
with
78 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package vacation_test | ||
|
||
import ( | ||
"bytes" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/paketo-buildpacks/packit/vacation" | ||
"github.com/sclevine/spec" | ||
|
||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func testVacationText(t *testing.T, context spec.G, it spec.S) { | ||
var ( | ||
Expect = NewWithT(t).Expect | ||
) | ||
|
||
context("when passed the reader of a text file", func() { | ||
var ( | ||
archive vacation.Archive | ||
tempDir string | ||
) | ||
|
||
it.Before(func() { | ||
var err error | ||
tempDir, err = os.MkdirTemp("", "vacation") | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
buffer := bytes.NewBuffer([]byte(`some contents`)) | ||
|
||
archive = vacation.NewArchive(buffer) | ||
}) | ||
|
||
it.After(func() { | ||
Expect(os.RemoveAll(tempDir)).To(Succeed()) | ||
}) | ||
|
||
it("writes a text file onto the path", func() { | ||
err := archive.Decompress(tempDir) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
content, err := os.ReadFile(filepath.Join(tempDir, "artifact")) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(content).To(Equal([]byte(`some contents`))) | ||
}) | ||
}) | ||
} |