@@ -17,6 +17,7 @@ limitations under the License.
17
17
package state
18
18
19
19
import (
20
+ "io/ioutil"
20
21
"os"
21
22
"reflect"
22
23
"strings"
@@ -30,8 +31,6 @@ import (
30
31
31
32
const testingCheckpoint = "cpumanager_checkpoint_test"
32
33
33
- var testingDir = os .TempDir ()
34
-
35
34
func TestCheckpointStateRestore (t * testing.T ) {
36
35
testCases := []struct {
37
36
description string
@@ -200,6 +199,12 @@ func TestCheckpointStateRestore(t *testing.T) {
200
199
},
201
200
}
202
201
202
+ // create temp dir
203
+ testingDir , err := ioutil .TempDir ("" , "cpumanager_state_test" )
204
+ if err != nil {
205
+ t .Fatal (err )
206
+ }
207
+ defer os .RemoveAll (testingDir )
203
208
// create checkpoint manager for testing
204
209
cpm , err := checkpointmanager .NewCheckpointManager (testingDir )
205
210
if err != nil {
@@ -258,6 +263,13 @@ func TestCheckpointStateStore(t *testing.T) {
258
263
},
259
264
}
260
265
266
+ // create temp dir
267
+ testingDir , err := ioutil .TempDir ("" , "cpumanager_state_test" )
268
+ if err != nil {
269
+ t .Fatal (err )
270
+ }
271
+ defer os .RemoveAll (testingDir )
272
+
261
273
cpm , err := checkpointmanager .NewCheckpointManager (testingDir )
262
274
if err != nil {
263
275
t .Fatalf ("could not create testing checkpoint manager: %v" , err )
@@ -324,6 +336,13 @@ func TestCheckpointStateHelpers(t *testing.T) {
324
336
},
325
337
}
326
338
339
+ // create temp dir
340
+ testingDir , err := ioutil .TempDir ("" , "cpumanager_state_test" )
341
+ if err != nil {
342
+ t .Fatal (err )
343
+ }
344
+ defer os .RemoveAll (testingDir )
345
+
327
346
cpm , err := checkpointmanager .NewCheckpointManager (testingDir )
328
347
if err != nil {
329
348
t .Fatalf ("could not create testing checkpoint manager: %v" , err )
@@ -376,6 +395,13 @@ func TestCheckpointStateClear(t *testing.T) {
376
395
377
396
for _ , tc := range testCases {
378
397
t .Run (tc .description , func (t * testing.T ) {
398
+ // create temp dir
399
+ testingDir , err := ioutil .TempDir ("" , "cpumanager_state_test" )
400
+ if err != nil {
401
+ t .Fatal (err )
402
+ }
403
+ defer os .RemoveAll (testingDir )
404
+
379
405
state , err := NewCheckpointState (testingDir , testingCheckpoint , "none" , nil )
380
406
if err != nil {
381
407
t .Fatalf ("could not create testing checkpointState instance: %v" , err )
0 commit comments