@@ -20,7 +20,7 @@ import (
2020 "context"
2121 "errors"
2222 "os"
23- "path"
23+ "path/filepath "
2424 "runtime"
2525 "sync"
2626 "testing"
@@ -43,13 +43,13 @@ func TestFSWatch(t *testing.T) {
4343 "empty" : {},
4444 "single cluster existing file" : {
4545 prepareFnc : func (basePath string ) error {
46- return os .WriteFile (path .Join (basePath , "c1.kubeconfig" ), []byte ("123" ), 0666 )
46+ return os .WriteFile (filepath .Join (basePath , "c1.kubeconfig" ), []byte ("123" ), 0666 )
4747 },
4848 clusters : map [string ]string {
4949 "c1" : "c1.kubeconfig" ,
5050 },
5151 opFnc : func (basePath string ) error {
52- return os .WriteFile (path .Join (basePath , "c1.kubeconfig" ), []byte ("123456" ), 0666 )
52+ return os .WriteFile (filepath .Join (basePath , "c1.kubeconfig" ), []byte ("123456" ), 0666 )
5353 },
5454 wantEventsForClusters : set .New ("c1" ),
5555 },
@@ -58,55 +58,55 @@ func TestFSWatch(t *testing.T) {
5858 "c1" : "c1.kubeconfig" ,
5959 },
6060 opFnc : func (basePath string ) error {
61- return os .WriteFile (path .Join (basePath , "c1.kubeconfig" ), []byte ("123456" ), 0666 )
61+ return os .WriteFile (filepath .Join (basePath , "c1.kubeconfig" ), []byte ("123456" ), 0666 )
6262 },
6363 wantEventsForClusters : set .New ("c1" ),
6464 },
6565 "single existing file deleted" : {
6666 prepareFnc : func (basePath string ) error {
67- return os .WriteFile (path .Join (basePath , "c1.kubeconfig" ), []byte ("123" ), 0666 )
67+ return os .WriteFile (filepath .Join (basePath , "c1.kubeconfig" ), []byte ("123" ), 0666 )
6868 },
6969 clusters : map [string ]string {
7070 "c1" : "c1.kubeconfig" ,
7171 },
7272 opFnc : func (basePath string ) error {
73- return os .Remove (path .Join (basePath , "c1.kubeconfig" ))
73+ return os .Remove (filepath .Join (basePath , "c1.kubeconfig" ))
7474 },
7575 wantEventsForClusters : set .New ("c1" ),
7676 },
7777 "single cluster file rename to" : {
7878 prepareFnc : func (basePath string ) error {
79- return os .WriteFile (path .Join (basePath , "c1.kubeconfig.old" ), []byte ("123" ), 0666 )
79+ return os .WriteFile (filepath .Join (basePath , "c1.kubeconfig.old" ), []byte ("123" ), 0666 )
8080 },
8181 clusters : map [string ]string {
8282 "c1" : "c1.kubeconfig" ,
8383 },
8484 opFnc : func (basePath string ) error {
85- return os .Rename (path .Join (basePath , "c1.kubeconfig.old" ), path .Join (basePath , "c1.kubeconfig" ))
85+ return os .Rename (filepath .Join (basePath , "c1.kubeconfig.old" ), filepath .Join (basePath , "c1.kubeconfig" ))
8686 },
8787 wantEventsForClusters : set .New ("c1" ),
8888 },
8989 "single cluster file rename from" : {
9090 prepareFnc : func (basePath string ) error {
91- return os .WriteFile (path .Join (basePath , "c1.kubeconfig" ), []byte ("123" ), 0666 )
91+ return os .WriteFile (filepath .Join (basePath , "c1.kubeconfig" ), []byte ("123" ), 0666 )
9292 },
9393 clusters : map [string ]string {
9494 "c1" : "c1.kubeconfig" ,
9595 },
9696 opFnc : func (basePath string ) error {
97- return os .Rename (path .Join (basePath , "c1.kubeconfig" ), path .Join (basePath , "c1.kubeconfig.new" ))
97+ return os .Rename (filepath .Join (basePath , "c1.kubeconfig" ), filepath .Join (basePath , "c1.kubeconfig.new" ))
9898 },
9999 wantEventsForClusters : set .New ("c1" ),
100100 },
101101 "single create link" : {
102102 prepareFnc : func (basePath string ) error {
103- return os .WriteFile (path .Join (basePath , "c1.kubeconfig.src" ), []byte ("123" ), 0666 )
103+ return os .WriteFile (filepath .Join (basePath , "c1.kubeconfig.src" ), []byte ("123" ), 0666 )
104104 },
105105 clusters : map [string ]string {
106106 "c1" : "c1.kubeconfig" ,
107107 },
108108 opFnc : func (basePath string ) error {
109- return os .Symlink (path .Join (basePath , "c1.kubeconfig.src" ), path .Join (basePath , "c1.kubeconfig" ))
109+ return os .Symlink (filepath .Join (basePath , "c1.kubeconfig.src" ), filepath .Join (basePath , "c1.kubeconfig" ))
110110 },
111111 wantEventsForClusters : set .New ("c1" ),
112112 },
@@ -116,16 +116,16 @@ func TestFSWatch(t *testing.T) {
116116 // fixed https://github.com/fsnotify/fsnotify/issues/636.
117117 skipOnDarwin : true ,
118118 prepareFnc : func (basePath string ) error {
119- if err := os .WriteFile (path .Join (basePath , "c1.kubeconfig.src" ), []byte ("123" ), 0666 ); err != nil {
119+ if err := os .WriteFile (filepath .Join (basePath , "c1.kubeconfig.src" ), []byte ("123" ), 0666 ); err != nil {
120120 return err
121121 }
122- return os .Symlink (path .Join (basePath , "c1.kubeconfig.src" ), path .Join (basePath , "c1.kubeconfig" ))
122+ return os .Symlink (filepath .Join (basePath , "c1.kubeconfig.src" ), filepath .Join (basePath , "c1.kubeconfig" ))
123123 },
124124 clusters : map [string ]string {
125125 "c1" : "c1.kubeconfig" ,
126126 },
127127 opFnc : func (basePath string ) error {
128- return os .Remove (path .Join (basePath , "c1.kubeconfig" ))
128+ return os .Remove (filepath .Join (basePath , "c1.kubeconfig" ))
129129 },
130130 wantEventsForClusters : set .New ("c1" ),
131131 },
@@ -168,7 +168,7 @@ func TestFSWatch(t *testing.T) {
168168
169169 gotAddErrors := map [string ]error {}
170170 for c , p := range tc .clusters {
171- if err := watcher .AddOrUpdate (c , path .Join (basePath , p )); err != nil {
171+ if err := watcher .AddOrUpdate (c , filepath .Join (basePath , p )); err != nil {
172172 gotAddErrors [c ] = err
173173 }
174174 }
@@ -196,10 +196,10 @@ func TestFSWatchAddRm(t *testing.T) {
196196 ctx , cancel := context .WithCancel (context .Background ())
197197 defer cancel ()
198198 basePath := t .TempDir ()
199- f1Path := path .Join (basePath , "file.one" )
200- f2Path := path .Join (basePath , "file.two" )
201- f3Dir := path .Join (basePath , "d1" )
202- f3Path := path .Join (f3Dir , "file.three" )
199+ f1Path := filepath .Join (basePath , "file.one" )
200+ f2Path := filepath .Join (basePath , "file.two" )
201+ f3Dir := filepath .Join (basePath , "d1" )
202+ f3Path := filepath .Join (f3Dir , "file.three" )
203203 steps := []struct {
204204 name string
205205 skipOnDarwin bool
0 commit comments