@@ -20,6 +20,7 @@ import (
20
20
"strings"
21
21
"testing"
22
22
23
+ "sigs.k8s.io/krew/internal/environment"
23
24
"sigs.k8s.io/krew/pkg/constants"
24
25
)
25
26
@@ -39,10 +40,11 @@ func TestKrewIndexAdd(t *testing.T) {
39
40
if err := test .Krew ("index" , "add" , "../../usr/bin" , constants .DefaultIndexURI ); err == nil {
40
41
t .Fatal ("expected index add with path characters to fail" )
41
42
}
42
- if _ , err := test .Krew ("index" , "add" , "foo" , test .TempDir ().Path ("index/" + constants .DefaultIndexName )).Run (); err != nil {
43
+ index := environment .NewPaths (test .Root ()).IndexPath (constants .DefaultIndexName )
44
+ if _ , err := test .Krew ("index" , "add" , "foo" , index ).Run (); err != nil {
43
45
t .Fatalf ("error adding new index: %v" , err )
44
46
}
45
- if _ , err := test .Krew ("index" , "add" , "foo" , test . TempDir (). Path ( " index/" + constants . DefaultIndexName ) ).Run (); err == nil {
47
+ if _ , err := test .Krew ("index" , "add" , "foo" , index ).Run (); err == nil {
46
48
t .Fatal ("expected adding same index to fail" )
47
49
}
48
50
}
@@ -73,7 +75,8 @@ func TestKrewIndexAddShowsSecurityWarning(t *testing.T) {
73
75
defer cleanup ()
74
76
75
77
test .WithDefaultIndex ()
76
- out := string (test .Krew ("index" , "add" , "foo" , test .TempDir ().Path ("index/" + constants .DefaultIndexName )).RunOrFailOutput ())
78
+ index := environment .NewPaths (test .Root ()).IndexPath (constants .DefaultIndexName )
79
+ out := string (test .Krew ("index" , "add" , "foo" , index ).RunOrFailOutput ())
77
80
if ! strings .Contains (out , "WARNING: You have added a new index" ) {
78
81
t .Errorf ("expected output to contain warning when adding custom index: %v" , out )
79
82
}
@@ -107,7 +110,7 @@ func TestKrewIndexList_NoIndexes(t *testing.T) {
107
110
defer cleanup ()
108
111
109
112
test .WithDefaultIndex ()
110
- index := test .TempDir (). Path ( "index" )
113
+ index := environment . NewPaths ( test .Root ()). IndexBase ( )
111
114
if err := os .RemoveAll (index ); err != nil {
112
115
t .Fatalf ("error removing default index: %v" , err )
113
116
}
0 commit comments