Skip to content

Commit

Permalink
Updates decompression logic
Browse files Browse the repository at this point in the history
- vacation is about to remove the TarGzipArchive in favor of wrapped
compression type into archive type. I have moved from specifying the
type of archive to using to generic archive type (long overdue hooray!)

- I removed the ioutil library as it is deprecated

Signed-off-by: Forest Eckhardt <feckhardt@pivotal.io>
  • Loading branch information
Sophie Wigmore authored and ForestEckhardt committed Dec 2, 2021
1 parent 7b23af5 commit d9c501c
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 96 deletions.
15 changes: 7 additions & 8 deletions cache_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package freezer_test
import (
"bytes"
"encoding/gob"
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand All @@ -25,7 +24,7 @@ func testCacheManager(t *testing.T, context spec.G, it spec.S) {

it.Before(func() {
var err error
cacheDir, err = ioutil.TempDir("", "cache")
cacheDir, err = os.MkdirTemp("", "cache")
Expect(err).ToNot(HaveOccurred())

cacheManager = freezer.NewCacheManager(cacheDir)
Expand All @@ -46,7 +45,7 @@ func testCacheManager(t *testing.T, context spec.G, it spec.S) {
err := gob.NewEncoder(b).Encode(&inputMap)
Expect(err).ToNot(HaveOccurred())

Expect(ioutil.WriteFile(filepath.Join(cacheDir, "buildpacks-cache.db"), b.Bytes(), os.ModePerm))
Expect(os.WriteFile(filepath.Join(cacheDir, "buildpacks-cache.db"), b.Bytes(), os.ModePerm))
})

it("returns the cache map stored in the buildpacks-cache.db folder", func() {
Expand Down Expand Up @@ -84,7 +83,7 @@ func testCacheManager(t *testing.T, context spec.G, it spec.S) {

context("unable to open the buildpack-cache.db", func() {
it.Before(func() {
Expect(ioutil.WriteFile(filepath.Join(cacheDir, "buildpacks-cache.db"), []byte{}, 0000))
Expect(os.WriteFile(filepath.Join(cacheDir, "buildpacks-cache.db"), []byte{}, 0000))
})
it("returns an error", func() {
err := cacheManager.Open()
Expand All @@ -94,7 +93,7 @@ func testCacheManager(t *testing.T, context spec.G, it spec.S) {

context("unable to open the buildpack-cache.db", func() {
it.Before(func() {
Expect(ioutil.WriteFile(filepath.Join(cacheDir, "buildpacks-cache.db"), []byte(`%%%`), os.ModePerm))
Expect(os.WriteFile(filepath.Join(cacheDir, "buildpacks-cache.db"), []byte(`%%%`), os.ModePerm))
})
it("returns an error", func() {
err := cacheManager.Open()
Expand Down Expand Up @@ -142,7 +141,7 @@ func testCacheManager(t *testing.T, context spec.G, it spec.S) {
context("when the key exists", func() {
context("and the file in uri exists", func() {
it.Before(func() {
Expect(ioutil.WriteFile(uri, []byte(`some-content`), 0644)).To(Succeed())
Expect(os.WriteFile(uri, []byte(`some-content`), 0644)).To(Succeed())
})

it("returns the entry and ok", func() {
Expand Down Expand Up @@ -175,7 +174,7 @@ func testCacheManager(t *testing.T, context spec.G, it spec.S) {
context("failure cases", func() {
context("the cached file is cannot be stated", func() {
it.Before(func() {
Expect(ioutil.WriteFile(uri, []byte(`some-content`), 0644)).To(Succeed())
Expect(os.WriteFile(uri, []byte(`some-content`), 0644)).To(Succeed())

Expect(os.Chmod(cacheDir, 0000)).To(Succeed())
})
Expand All @@ -201,7 +200,7 @@ func testCacheManager(t *testing.T, context spec.G, it spec.S) {

uri = filepath.Join(cacheDir, "some-file")

Expect(ioutil.WriteFile(uri, []byte(`some content`), 0644)).To(Succeed())
Expect(os.WriteFile(uri, []byte(`some content`), 0644)).To(Succeed())

cacheManager.Cache = freezer.CacheDB{"some-buildpack": freezer.CacheEntry{Version: "1.2.3", URI: uri}}
})
Expand Down
3 changes: 1 addition & 2 deletions file_system_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package freezer_test

import (
"io/ioutil"
"os"
"testing"

Expand All @@ -15,7 +14,7 @@ func testFileSystem(t *testing.T, context spec.G, it spec.S) {

context("TempDir", func() {
it("returns the value given from the TempDir function", func() {
filename, err := ioutil.TempDir("", "tempDir")
filename, err := os.MkdirTemp("", "tempDir")
defer os.RemoveAll(filename)

fileSystem := freezer.NewFileSystem(func(string, string) (string, error) {
Expand Down
10 changes: 5 additions & 5 deletions github/release_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package github_test

import (
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"net/http/httputil"
Expand Down Expand Up @@ -178,7 +178,7 @@ func testReleaseService(t *testing.T, context spec.G, it spec.S) {
})
Expect(err).ToNot(HaveOccurred())

content, err := ioutil.ReadAll(response)
content, err := io.ReadAll(response)
Expect(err).ToNot(HaveOccurred())
Expect(string(content)).To(Equal("some-asset"))

Expand Down Expand Up @@ -214,7 +214,7 @@ func testReleaseService(t *testing.T, context spec.G, it spec.S) {
})
Expect(err).ToNot(HaveOccurred())

content, err := ioutil.ReadAll(response)
content, err := io.ReadAll(response)
Expect(err).ToNot(HaveOccurred())
Expect(string(content)).To(Equal("some-asset"))

Expand Down Expand Up @@ -287,7 +287,7 @@ func testReleaseService(t *testing.T, context spec.G, it spec.S) {
response, err := service.GetReleaseTarball(fmt.Sprintf("%s/some-tarball-url", api.URL))
Expect(err).ToNot(HaveOccurred())

content, err := ioutil.ReadAll(response)
content, err := io.ReadAll(response)
Expect(err).ToNot(HaveOccurred())
Expect(string(content)).To(Equal("some-tarball"))

Expand Down Expand Up @@ -321,7 +321,7 @@ func testReleaseService(t *testing.T, context spec.G, it spec.S) {
response, err := service.GetReleaseTarball(fmt.Sprintf("%s/some-tarball-url", api.URL))
Expect(err).ToNot(HaveOccurred())

content, err := ioutil.ReadAll(response)
content, err := io.ReadAll(response)
Expect(err).ToNot(HaveOccurred())
Expect(string(content)).To(Equal("some-tarball"))

Expand Down
10 changes: 6 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
module github.com/ForestEckhardt/freezer

go 1.13
go 1.16

require (
github.com/oklog/ulid v1.3.1
github.com/onsi/gomega v1.10.4
github.com/paketo-buildpacks/occam v0.0.22
github.com/paketo-buildpacks/packit v0.5.0
github.com/onsi/gomega v1.17.0
github.com/paketo-buildpacks/occam v0.2.0
github.com/paketo-buildpacks/packit v1.3.1
github.com/sclevine/spec v1.4.0
golang.org/x/net v0.0.0-20211201190559-0a0e4e1bb54c // indirect
golang.org/x/text v0.3.7 // indirect
)
Loading

0 comments on commit d9c501c

Please sign in to comment.