This repository was archived by the owner on Mar 27, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed
Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ import (
2828 pkgutil "github.com/GoogleContainerTools/container-diff/pkg/util"
2929 "github.com/GoogleContainerTools/container-diff/util"
3030 homedir "github.com/mitchellh/go-homedir"
31+ "github.com/pkg/errors"
3132 "github.com/sirupsen/logrus"
3233 "github.com/spf13/cobra"
3334 "github.com/spf13/pflag"
@@ -151,7 +152,7 @@ func getCacheDir(imageName string) (string, error) {
151152 if cacheDir == "" {
152153 dir , err := homedir .Dir ()
153154 if err != nil {
154- return "" , err
155+ return "" , errors . Wrap ( err , "retrieving home dir" )
155156 } else {
156157 cacheDir = dir
157158 }
Original file line number Diff line number Diff line change @@ -31,15 +31,18 @@ type testpair struct {
3131}
3232
3333func TestCacheDir (t * testing.T ) {
34- homeDir , _ := homedir .Dir ()
34+ homeDir , err := homedir .Dir ()
35+ if err != nil {
36+ t .Errorf ("\n Error getting home dir" )
37+ }
38+
3539 tests := []struct {
3640 name string
3741 cliFlag string
3842 envVar string
3943 expectedDir string
4044 imageName string
4145 }{
42- // name, cliFlag, envVar, expectedDir
4346 {
4447 name : "default cache is at $HOME" ,
4548 cliFlag : "" ,
@@ -80,7 +83,10 @@ func TestCacheDir(t *testing.T) {
8083 cacheDir = tt .cliFlag
8184
8285 // call getCacheDir and make sure return is equal to expected
83- actualDir , _ := getCacheDir (tt .imageName )
86+ actualDir , err := getCacheDir (tt .imageName )
87+ if err != nil {
88+ t .Errorf ("%s\n Error getting cache dir" , tt .name )
89+ }
8490
8591 if path .Dir (actualDir ) != tt .expectedDir {
8692 t .Errorf ("%s\n Expected: %v\n Got: %v" , tt .name , tt .expectedDir , actualDir )
You can’t perform that action at this time.
0 commit comments