forked from paketo-buildpacks/packit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvacation_text_test.go
49 lines (38 loc) · 1001 Bytes
/
vacation_text_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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`)))
})
})
}