@@ -3,7 +3,6 @@ package freezer_test
3
3
import (
4
4
"bytes"
5
5
"encoding/gob"
6
- "io/ioutil"
7
6
"os"
8
7
"path/filepath"
9
8
"testing"
@@ -25,7 +24,7 @@ func testCacheManager(t *testing.T, context spec.G, it spec.S) {
25
24
26
25
it .Before (func () {
27
26
var err error
28
- cacheDir , err = ioutil . TempDir ("" , "cache" )
27
+ cacheDir , err = os . MkdirTemp ("" , "cache" )
29
28
Expect (err ).ToNot (HaveOccurred ())
30
29
31
30
cacheManager = freezer .NewCacheManager (cacheDir )
@@ -46,7 +45,7 @@ func testCacheManager(t *testing.T, context spec.G, it spec.S) {
46
45
err := gob .NewEncoder (b ).Encode (& inputMap )
47
46
Expect (err ).ToNot (HaveOccurred ())
48
47
49
- Expect (ioutil .WriteFile (filepath .Join (cacheDir , "buildpacks-cache.db" ), b .Bytes (), os .ModePerm ))
48
+ Expect (os .WriteFile (filepath .Join (cacheDir , "buildpacks-cache.db" ), b .Bytes (), os .ModePerm ))
50
49
})
51
50
52
51
it ("returns the cache map stored in the buildpacks-cache.db folder" , func () {
@@ -84,7 +83,7 @@ func testCacheManager(t *testing.T, context spec.G, it spec.S) {
84
83
85
84
context ("unable to open the buildpack-cache.db" , func () {
86
85
it .Before (func () {
87
- Expect (ioutil .WriteFile (filepath .Join (cacheDir , "buildpacks-cache.db" ), []byte {}, 0000 ))
86
+ Expect (os .WriteFile (filepath .Join (cacheDir , "buildpacks-cache.db" ), []byte {}, 0000 ))
88
87
})
89
88
it ("returns an error" , func () {
90
89
err := cacheManager .Open ()
@@ -94,7 +93,7 @@ func testCacheManager(t *testing.T, context spec.G, it spec.S) {
94
93
95
94
context ("unable to open the buildpack-cache.db" , func () {
96
95
it .Before (func () {
97
- Expect (ioutil .WriteFile (filepath .Join (cacheDir , "buildpacks-cache.db" ), []byte (`%%%` ), os .ModePerm ))
96
+ Expect (os .WriteFile (filepath .Join (cacheDir , "buildpacks-cache.db" ), []byte (`%%%` ), os .ModePerm ))
98
97
})
99
98
it ("returns an error" , func () {
100
99
err := cacheManager .Open ()
@@ -142,7 +141,7 @@ func testCacheManager(t *testing.T, context spec.G, it spec.S) {
142
141
context ("when the key exists" , func () {
143
142
context ("and the file in uri exists" , func () {
144
143
it .Before (func () {
145
- Expect (ioutil .WriteFile (uri , []byte (`some-content` ), 0644 )).To (Succeed ())
144
+ Expect (os .WriteFile (uri , []byte (`some-content` ), 0644 )).To (Succeed ())
146
145
})
147
146
148
147
it ("returns the entry and ok" , func () {
@@ -175,7 +174,7 @@ func testCacheManager(t *testing.T, context spec.G, it spec.S) {
175
174
context ("failure cases" , func () {
176
175
context ("the cached file is cannot be stated" , func () {
177
176
it .Before (func () {
178
- Expect (ioutil .WriteFile (uri , []byte (`some-content` ), 0644 )).To (Succeed ())
177
+ Expect (os .WriteFile (uri , []byte (`some-content` ), 0644 )).To (Succeed ())
179
178
180
179
Expect (os .Chmod (cacheDir , 0000 )).To (Succeed ())
181
180
})
@@ -201,7 +200,7 @@ func testCacheManager(t *testing.T, context spec.G, it spec.S) {
201
200
202
201
uri = filepath .Join (cacheDir , "some-file" )
203
202
204
- Expect (ioutil .WriteFile (uri , []byte (`some content` ), 0644 )).To (Succeed ())
203
+ Expect (os .WriteFile (uri , []byte (`some content` ), 0644 )).To (Succeed ())
205
204
206
205
cacheManager .Cache = freezer.CacheDB {"some-buildpack" : freezer.CacheEntry {Version : "1.2.3" , URI : uri }}
207
206
})
0 commit comments