File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed
Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -35,3 +35,50 @@ func TestDetectGitRepo(t *testing.T) {
3535 t .Fatal ("Test timed out" )
3636 }
3737}
38+
39+ func TestExcludedDirectory (t * testing.T ) {
40+ d , err := os .MkdirTemp (os .TempDir (), "test" )
41+ if err != nil {
42+ t .Error (err )
43+ }
44+ defer os .RemoveAll (d )
45+ err = os .MkdirAll (d + "/.hidden/test" , 0750 )
46+ if err != nil {
47+ t .Error (err )
48+ }
49+ cmd := exec .Command ("git" , "init" )
50+ cmd .Dir = d + "/.hidden/test"
51+ err = cmd .Run ()
52+ if err != nil {
53+ t .Error (err )
54+ }
55+ err = os .MkdirAll (d + "/node_modules/test" , 0750 )
56+ if err != nil {
57+ t .Error (err )
58+ }
59+ cmd = exec .Command ("git" , "init" )
60+ cmd .Dir = d + "/node_modules/test"
61+ err = cmd .Run ()
62+ if err != nil {
63+ t .Error (err )
64+ }
65+
66+ output := make (chan repo )
67+ go func () {
68+ _ = collectDirtyRepos (d , output )
69+ defer close (output )
70+ }()
71+
72+ detected := 0
73+ select {
74+ case result := <- output :
75+ // Closed channel returning the zero value of the underlying type, thus check non-emptyness..
76+ if result .path != "" {
77+ detected ++
78+ }
79+ case <- time .After (2 * time .Second ):
80+ t .Fatal ("Test timed out" )
81+ }
82+
83+ require .Equal (t , 0 , detected )
84+ }
You can’t perform that action at this time.
0 commit comments