@@ -21,7 +21,6 @@ import (
2121 "path/filepath"
2222 "testing"
2323
24- paths "github.com/arduino/go-paths-helper"
2524 "github.com/stretchr/testify/require"
2625)
2726
@@ -39,45 +38,6 @@ func tmpDirOrDie() string {
3938 return dir
4039}
4140
42- func TestSearchConfigTreeNotFound (t * testing.T ) {
43- tmp := tmpDirOrDie ()
44- require .Empty (t , searchConfigTree (paths .New (tmp )))
45- }
46-
47- func TestSearchConfigTreeSameFolder (t * testing.T ) {
48- tmp := tmpDirOrDie ()
49- defer os .RemoveAll (tmp )
50- _ , err := os .Create (filepath .Join (tmp , "arduino-cli.yaml" ))
51- require .Nil (t , err )
52- require .Equal (t , tmp , searchConfigTree (paths .New (tmp )).String ())
53- }
54-
55- func TestSearchConfigTreeInParent (t * testing.T ) {
56- tmp := tmpDirOrDie ()
57- defer os .RemoveAll (tmp )
58- target := filepath .Join (tmp , "foo" , "bar" )
59- err := os .MkdirAll (target , os .ModePerm )
60- require .Nil (t , err )
61- _ , err = os .Create (filepath .Join (tmp , "arduino-cli.yaml" ))
62- require .Nil (t , err )
63- require .Equal (t , tmp , searchConfigTree (paths .New (target )).String ())
64- }
65-
66- var result * paths.Path
67-
68- func BenchmarkSearchConfigTree (b * testing.B ) {
69- tmp := tmpDirOrDie ()
70- defer os .RemoveAll (tmp )
71- target := filepath .Join (tmp , "foo" , "bar" , "baz" )
72- os .MkdirAll (target , os .ModePerm )
73-
74- var s * paths.Path
75- for n := 0 ; n < b .N ; n ++ {
76- s = searchConfigTree (paths .New (target ))
77- }
78- result = s
79- }
80-
8141func TestInit (t * testing.T ) {
8242 tmp := tmpDirOrDie ()
8343 defer os .RemoveAll (tmp )
@@ -100,16 +60,16 @@ func TestInit(t *testing.T) {
10060}
10161
10262func TestFindConfigFile (t * testing.T ) {
103- configFile := FindConfigFileInArgsOrWorkingDirectory ([]string {"--config-file" })
63+ configFile := FindConfigFileInArgs ([]string {"--config-file" })
10464 require .Equal (t , "" , configFile )
10565
106- configFile = FindConfigFileInArgsOrWorkingDirectory ([]string {"--config-file" , "some/path/to/config" })
66+ configFile = FindConfigFileInArgs ([]string {"--config-file" , "some/path/to/config" })
10767 require .Equal (t , "some/path/to/config" , configFile )
10868
109- configFile = FindConfigFileInArgsOrWorkingDirectory ([]string {"--config-file" , "some/path/to/config/arduino-cli.yaml" })
69+ configFile = FindConfigFileInArgs ([]string {"--config-file" , "some/path/to/config/arduino-cli.yaml" })
11070 require .Equal (t , "some/path/to/config/arduino-cli.yaml" , configFile )
11171
112- configFile = FindConfigFileInArgsOrWorkingDirectory ([]string {})
72+ configFile = FindConfigFileInArgs ([]string {})
11373 require .Equal (t , "" , configFile )
11474
11575 // Create temporary directories
@@ -124,14 +84,14 @@ func TestFindConfigFile(t *testing.T) {
12484 require .Nil (t , err )
12585 f .Close ()
12686
127- configFile = FindConfigFileInArgsOrWorkingDirectory ([]string {})
87+ configFile = FindConfigFileInArgs ([]string {})
12888 require .Equal (t , filepath .Join (tmp , "foo" , "arduino-cli.yaml" ), configFile )
12989
13090 // Create another config file
13191 f , err = os .Create (filepath .Join (target , "arduino-cli.yaml" ))
13292 require .Nil (t , err )
13393 f .Close ()
13494
135- configFile = FindConfigFileInArgsOrWorkingDirectory ([]string {})
95+ configFile = FindConfigFileInArgs ([]string {})
13696 require .Equal (t , filepath .Join (target , "arduino-cli.yaml" ), configFile )
13797}
0 commit comments