1
- using System . IO ;
1
+ using System ;
2
+ using System . IO ;
2
3
using System . Linq ;
3
4
using System . Threading ;
4
5
using System . Threading . Tasks ;
@@ -13,33 +14,33 @@ namespace ConfigCat.Cli.Tests;
13
14
public class IgnoreTests
14
15
{
15
16
[ Theory ]
16
- [ InlineData ( "a" , new [ ] { @"a\ .ignore", @"a\b\ .ignore", @"a\c\f\ .ignore" } , 8 ) ]
17
- [ InlineData ( @"a\ b", new [ ] { @"a\ .ignore", @"a\b\ .ignore" } , 4 ) ]
18
- [ InlineData ( @"a\ c", new [ ] { @"a\ .ignore", @"a\c\f\ .ignore" } , 3 ) ]
19
- [ InlineData ( @"a\c\ f", new [ ] { @"a\ .ignore", @"a\c\f\ .ignore" } , 1 ) ]
20
- [ InlineData ( @"a\c\ g", new [ ] { @"a\ .ignore" } , 1 ) ]
17
+ [ InlineData ( "a" , new [ ] { "a/ .ignore", "a/b/ .ignore", "a/c/f/ .ignore" } , 8 ) ]
18
+ [ InlineData ( "a/ b", new [ ] { "a/ .ignore", "a/b/ .ignore" } , 4 ) ]
19
+ [ InlineData ( "a/ c", new [ ] { "a/ .ignore", "a/c/f/ .ignore" } , 3 ) ]
20
+ [ InlineData ( "a/c/ f", new [ ] { "a/ .ignore", "a/c/f/ .ignore" } , 1 ) ]
21
+ [ InlineData ( "a/c/ g", new [ ] { "a/ .ignore" } , 1 ) ]
21
22
public async Task Test_IgnoreFile_Collect ( string searchDir , string [ ] expectedIgnoreFiles , int fileCount )
22
23
{
23
24
var executingDir = new DirectoryInfo ( Path . Combine ( Directory . GetCurrentDirectory ( ) , searchDir ) ) ;
24
25
var client = new GitClient ( new Output ( new CliOptions ( ) ) ) ;
25
26
var repoDir = await client . GetRepoRootDirectoryOrNull ( executingDir ) ;
26
27
var ( ignoreFiles , files ) = FileCollector . GetFilesFromWorkSpace ( executingDir , repoDir ) ;
27
28
28
- var expectations = expectedIgnoreFiles . Select ( f => Path . Combine ( Directory . GetCurrentDirectory ( ) , f ) )
29
- . Concat ( [ Path . Combine ( repoDir . FullName , ".gitignore" ) ] ) . Order ( ) . ToArray ( ) ;
29
+ var expectations = expectedIgnoreFiles . Select ( f => Path . Combine ( Directory . GetCurrentDirectory ( ) , f ) . WithSlashes ( ) )
30
+ . Concat ( [ Path . Combine ( repoDir . FullName , ".gitignore" ) . WithSlashes ( ) ] ) . Order ( ) . ToArray ( ) ;
30
31
31
- var ignoreFileNames = ignoreFiles . Select ( f => f . FullName ) . Order ( ) ;
32
+ var ignoreFileNames = ignoreFiles . Select ( f => f . FullName . WithSlashes ( ) ) . Order ( ) ;
32
33
33
34
Assert . Equal ( expectations , ignoreFileNames ) ;
34
35
Assert . Equal ( fileCount , files . Count ( ) ) ;
35
36
}
36
37
37
38
[ Theory ]
38
- [ InlineData ( "a" , new [ ] { @"a\b\d\ d.txt", @"a\b\d\ h.txt", @"a\b\e\ e.txt" } ) ]
39
- [ InlineData ( @"a\ b", new [ ] { @"a\b\d\ d.txt", @"a\b\d\ h.txt", @"a\b\e\ e.txt" } ) ]
40
- [ InlineData ( @"a\b\ d", new [ ] { @"a\b\d\ d.txt", @"a\b\d\ h.txt" } ) ]
41
- [ InlineData ( @"a\b\ e", new [ ] { @"a\b\e\ e.txt" } ) ]
42
- [ InlineData ( @"a\ c", new string [ 0 ] ) ]
39
+ [ InlineData ( "a" , new [ ] { "a/b/d/ d.txt", "a/b/d/ h.txt", "a/b/e/ e.txt" } ) ]
40
+ [ InlineData ( "a/ b", new [ ] { "a/b/d/ d.txt", "a/b/d/ h.txt", "a/b/e/ e.txt" } ) ]
41
+ [ InlineData ( "a/b/ d", new [ ] { "a/b/d/ d.txt", "a/b/d/ h.txt" } ) ]
42
+ [ InlineData ( "a/b/ e", new [ ] { "a/b/e/ e.txt" } ) ]
43
+ [ InlineData ( "a/ c", new string [ 0 ] ) ]
43
44
public async Task Test_IgnoreFile_Process_With_GitIgnore ( string searchDir , string [ ] expectedFiles )
44
45
{
45
46
var executingDir = new DirectoryInfo ( Path . Combine ( Directory . GetCurrentDirectory ( ) , searchDir ) ) ;
@@ -48,31 +49,31 @@ public async Task Test_IgnoreFile_Process_With_GitIgnore(string searchDir, strin
48
49
var fileCollector = new FileCollector ( new Output ( new CliOptions ( ) ) ) ;
49
50
var files = ( await fileCollector . CollectAsync ( executingDir , repoDir , CancellationToken . None ) ) . ToArray ( ) ;
50
51
51
- var expectations = expectedFiles . Select ( f => Path . Combine ( Directory . GetCurrentDirectory ( ) , f ) ) . Order ( )
52
+ var expectations = expectedFiles . Select ( f => Path . Combine ( Directory . GetCurrentDirectory ( ) , f ) . WithSlashes ( ) ) . Order ( )
52
53
. ToArray ( ) ;
53
- var fileNames = files . Select ( f => f . FullName ) . Order ( ) ;
54
+ var fileNames = files . Select ( f => f . FullName . WithSlashes ( ) ) . Order ( ) ;
54
55
55
56
Assert . Equal ( expectations , fileNames ) ;
56
57
}
57
58
58
59
[ Theory ]
59
60
[ InlineData ( "a" ,
60
- new [ ] { @"a\ a.txt", @"a\b\d\ d.txt", @"a\b\d\ h.txt", @"a\b\e\ e.txt", @"a\c\ c.txt", @"a\c\g\ g.txt" } ) ]
61
- [ InlineData ( @"a\ b", new [ ] { @"a\b\d\ d.txt", @"a\b\d\ h.txt", @"a\b\e\ e.txt" } ) ]
62
- [ InlineData ( @"a\b\ d", new [ ] { @"a\b\d\ d.txt", @"a\b\d\ h.txt" } ) ]
63
- [ InlineData ( @"a\b\ e", new [ ] { @"a\b\e\ e.txt" } ) ]
64
- [ InlineData ( @"a\ c", new [ ] { @"a\c\ c.txt", @"a\c\g\ g.txt" } ) ]
65
- [ InlineData ( @"a\c\ g", new [ ] { @"a\c\g\ g.txt" } ) ]
61
+ new [ ] { "a/ a.txt", "a/b/d/ d.txt", "a/b/d/ h.txt", "a/b/e/ e.txt", "a/c/ c.txt", "a/c/g/ g.txt" } ) ]
62
+ [ InlineData ( "a/ b", new [ ] { "a/b/d/ d.txt", "a/b/d/ h.txt", "a/b/e/ e.txt" } ) ]
63
+ [ InlineData ( "a/b/ d", new [ ] { "a/b/d/ d.txt", "a/b/d/ h.txt" } ) ]
64
+ [ InlineData ( "a/b/ e", new [ ] { "a/b/e/ e.txt" } ) ]
65
+ [ InlineData ( "a/ c", new [ ] { "a/c/ c.txt", "a/c/g/ g.txt" } ) ]
66
+ [ InlineData ( "a/c/ g", new [ ] { "a/c/g/ g.txt" } ) ]
66
67
public async Task Test_IgnoreFile_Process_Without_GitIgnore ( string searchDir , string [ ] expectedFiles )
67
68
{
68
69
var executingDir = new DirectoryInfo ( Path . Combine ( Directory . GetCurrentDirectory ( ) , searchDir ) ) ;
69
70
var repoDir = new DirectoryInfo ( Directory . GetCurrentDirectory ( ) ) ;
70
71
var fileCollector = new FileCollector ( new Output ( new CliOptions ( ) ) ) ;
71
72
var files = ( await fileCollector . CollectAsync ( executingDir , repoDir , CancellationToken . None ) ) . ToArray ( ) ;
72
73
73
- var expectations = expectedFiles . Select ( f => Path . Combine ( Directory . GetCurrentDirectory ( ) , f ) ) . Order ( )
74
+ var expectations = expectedFiles . Select ( f => Path . Combine ( Directory . GetCurrentDirectory ( ) , f ) . WithSlashes ( ) ) . Order ( )
74
75
. ToArray ( ) ;
75
- var fileNames = files . Select ( f => f . FullName ) . Order ( ) ;
76
+ var fileNames = files . Select ( f => f . FullName . WithSlashes ( ) ) . Order ( ) ;
76
77
77
78
Assert . Equal ( expectations , fileNames ) ;
78
79
}
0 commit comments