Skip to content

Commit 2fb1580

Browse files
committed
fix
1 parent fe127b0 commit 2fb1580

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

TeamTools.Linter.CommandLineTests/UnitTests/CommandLintOptionsTests.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,20 @@ namespace TeamTools.TSQL.Linter.CommandLineTests
99
public class CommandLintOptionsTests
1010
{
1111
private Dictionary<string, List<string>> argVariants;
12+
#if Windows
13+
private const string BasePath = @"c:\";
14+
#else
15+
private const string BasePath = @"/home/";
16+
#endif
1217

1318
[SetUp]
1419
public void Setup()
1520
{
1621
argVariants = new Dictionary<string, List<string>>
1722
{
18-
{ "scan dir", new List<string> { "--config", "c:\\conf.json", "--dir", "c:\\src" } },
19-
{ "scan file", new List<string> { "--config", "c:\\conf.json", "--file", "c:\\src\\file.sql" } },
20-
{ "scan diff", new List<string> { "--config", "c:\\conf.json", "--dir", "c:\\src\\proj", "--diff", "--format", "json", "--basepath", "c:\\src", "--output", "c:\\report.json", "--verbose" } },
23+
{ "scan dir", new List<string> { "--config", BasePath + "conf.json", "--dir", BasePath + "src" } },
24+
{ "scan file", new List<string> { "--config", BasePath + "conf.json", "--file", BasePath + "src/file.sql" } },
25+
{ "scan diff", new List<string> { "--config", BasePath + "conf.json", "--dir", BasePath + "src/proj", "--diff", "--format", "json", "--basepath", BasePath + "src", "--output", BasePath + "report.json", "--verbose" } },
2126
};
2227
}
2328

@@ -42,10 +47,10 @@ public void TestAllArgumentsExtractedCorrectly()
4247
.WithNotParsed(err => Assert.Fail(string.Join(";", err)));
4348

4449
Assert.That(parsedOpts, Is.Not.Null);
45-
Assert.That(parsedOpts.ConfigFile, Is.EqualTo("c:\\conf.json"));
46-
Assert.That(parsedOpts.DirectoryName, Is.EqualTo("c:\\src\\proj"));
47-
Assert.That(parsedOpts.BasePath, Is.EqualTo("c:\\src"));
48-
Assert.That(parsedOpts.OutputFile, Is.EqualTo("c:\\report.json"));
50+
Assert.That(parsedOpts.ConfigFile, Is.EqualTo(BasePath + "conf.json"));
51+
Assert.That(parsedOpts.DirectoryName, Is.EqualTo(BasePath + "src/proj"));
52+
Assert.That(parsedOpts.BasePath, Is.EqualTo(BasePath + "src"));
53+
Assert.That(parsedOpts.OutputFile, Is.EqualTo(BasePath + "report.json"));
4954
Assert.That(parsedOpts.Format, Is.EqualTo(OutputFileFormat.JSON));
5055
Assert.That(string.IsNullOrEmpty(parsedOpts.FileListSource), Is.True);
5156
Assert.That(string.IsNullOrEmpty(parsedOpts.FileName), Is.True);

TeamTools.Linter.CommandLineTests/UnitTests/FileReporterTests.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,21 @@ public void TestReportResultsSendsToStream()
3636
[Test]
3737
public void TestJsonReportFormatterOutput()
3838
{
39+
#if Windows
40+
const string basePath = @"c:\";
41+
#else
42+
const string basePath = @"/home/";
43+
#endif
3944
string expectedOutput = @"{'LINT':{'language':'TSQL','files':[{'name':'filename.txt','issues':[{'line':2,'col':3,'reason':'Failure','evidence':'','category':'CODE_SMELL','severity':'MAJOR','rule':'RULEID'}]}]}}"
4045
.Replace('\'', '"');
41-
var formatter = new JsonReportFormatter(@"c:\test");
46+
var formatter = new JsonReportFormatter(Path.Combine(basePath, "test"));
4247
var output = new StringWriter();
4348
var issues = new List<RuleViolation>();
4449
issues.Add(new RuleViolation
4550
{
4651
Line = 2,
4752
Column = 3,
48-
FileName = @"c:\test\filename.txt",
53+
FileName = Path.Combine(basePath, "test", "filename.txt"),
4954
RuleId = "RULEID",
5055
Text = "Failure",
5156
});

0 commit comments

Comments
 (0)