Skip to content

Commit d79d29a

Browse files
committed
make tests pass on unix
1 parent 1cded2a commit d79d29a

File tree

7 files changed

+44
-8
lines changed

7 files changed

+44
-8
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace GitHubIssuesParserCli.Tests.Auxiliary;
2+
3+
internal static class OsDependantOutput
4+
{
5+
public static string ReadAllText(string filepath)
6+
{
7+
return Environment.OSVersion.Platform == PlatformID.Unix
8+
? NormalizedLineEndingsFileReader.ReadAllText($"{filepath}-unix.txt")
9+
: NormalizedLineEndingsFileReader.ReadAllText($"{filepath}-windows.txt");
10+
}
11+
}

GitHubIssueFormsParser/tests/GitHubIssuesParserCli.Tests/CliIntegration/CliIntegrationTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public async Task NoArguments()
1818
app.CliApplicationBuilder.UseConsole(console);
1919
await app.RunAsync();
2020
var output = console.ReadOutputString();
21-
var expectedOutput = NormalizedLineEndingsFileReader.ReadAllText("./TestFiles/CliOutputNoArgs.txt");
21+
var expectedOutput = OsDependantOutput.ReadAllText("./TestFiles/CliOutputNoArgs");
2222
output.ShouldEndWith(expectedOutput);
2323
}
2424

@@ -35,7 +35,7 @@ public async Task IssueBodyOptionIsRequired()
3535
var args = new[] { "parse-issue-form", "--template-filepath", "some filepath" };
3636
await app.RunAsync(args);
3737
var output = console.ReadOutputString();
38-
var expectedOutput = NormalizedLineEndingsFileReader.ReadAllText("./TestFiles/CliOutputUsage.txt");
38+
var expectedOutput = OsDependantOutput.ReadAllText("./TestFiles/CliOutputUsage");
3939
output.ShouldEndWith(expectedOutput);
4040
}
4141

@@ -52,7 +52,7 @@ public async Task TemplateFilepathOptionIsRequired()
5252
var args = new[] { "parse-issue-form", "--issue-body", "some issue body" };
5353
await app.RunAsync(args);
5454
var output = console.ReadOutputString();
55-
var expectedOutput = NormalizedLineEndingsFileReader.ReadAllText("./TestFiles/CliOutputUsage.txt");
55+
var expectedOutput = OsDependantOutput.ReadAllText("./TestFiles/CliOutputUsage");
5656
output.ShouldEndWith(expectedOutput);
5757
}
5858

@@ -71,7 +71,7 @@ public async Task IssueBodyOptionValidation(string issueBody)
7171
var args = new[] { "parse-issue-form", "--issue-body", issueBody, "--template-filepath", "some filepath" };
7272
await app.RunAsync(args);
7373
var error = console.ReadErrorString();
74-
var expectedError = File.ReadAllText("./TestFiles/CliErrorIssueBodyValidation.txt");
74+
var expectedError = NormalizedLineEndingsFileReader.ReadAllText("./TestFiles/CliErrorIssueBodyValidation.txt");
7575
expectedError.ShouldBe(error);
7676
}
7777

@@ -91,7 +91,7 @@ public async Task TemplateFilepathOptionValidation(string templateFilepath)
9191
var args = new[] { "parse-issue-form", "--issue-body", "some body", "--template-filepath", templateFilepath };
9292
await app.RunAsync(args);
9393
var error = console.ReadErrorString();
94-
var expectedError = File.ReadAllText("./TestFiles/CliErrorTemplateFilepathValidation.txt");
94+
var expectedError = NormalizedLineEndingsFileReader.ReadAllText("./TestFiles/CliErrorTemplateFilepathValidation.txt");
9595
expectedError.ShouldBe(error);
9696
}
9797

@@ -109,7 +109,7 @@ public async Task TemplateFilepathOptionValidation2()
109109
var args = new[] { "parse-issue-form", "--issue-body", "some body", "--template-filepath", "non-existent-file.txt" };
110110
await app.RunAsync(args);
111111
var error = console.ReadErrorString();
112-
var expectedError = File.ReadAllText("./TestFiles/CliErrorTemplateFilepathValidation2.txt");
112+
var expectedError = NormalizedLineEndingsFileReader.ReadAllText("./TestFiles/CliErrorTemplateFilepathValidation2.txt");
113113
expectedError.ShouldBe(error);
114114
}
115115

GitHubIssueFormsParser/tests/GitHubIssuesParserCli.Tests/GitHubIssuesParserCli.Tests.csproj

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,16 @@
3333
<None Update="TestFiles\CliErrorIssueBodyValidation.txt">
3434
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
3535
</None>
36-
<None Update="TestFiles\CliOutputUsage.txt">
36+
<None Update="TestFiles\CliOutputNoArgs-unix.txt">
3737
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
3838
</None>
39-
<None Update="TestFiles\CliOutputNoArgs.txt">
39+
<None Update="TestFiles\CliOutputUsage-windows.txt">
40+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
41+
</None>
42+
<None Update="TestFiles\CliOutputUsage-unix.txt">
43+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
44+
</None>
45+
<None Update="TestFiles\CliOutputNoArgs-windows.txt">
4046
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
4147
</None>
4248
<None Update="TestFiles\InvalidTemplate2.yml">
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
USAGE
2+
dotnet testhost.dll [options]
3+
dotnet testhost.dll [command] [...]
4+
5+
OPTIONS
6+
-h|--help Shows help text.
7+
--version Shows version information.
8+
9+
COMMANDS
10+
parse-issue-form
11+
12+
You can run `dotnet testhost.dll [command] --help` to show help on a specific command.

GitHubIssueFormsParser/tests/GitHubIssuesParserCli.Tests/TestFiles/CliOutputNoArgs.txt renamed to GitHubIssueFormsParser/tests/GitHubIssuesParserCli.Tests/TestFiles/CliOutputNoArgs-windows.txt

File renamed without changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
USAGE
2+
dotnet testhost.dll parse-issue-form --issue-body <value> --template-filepath <value> [options]
3+
4+
OPTIONS
5+
* -i|--issue-body The body of the GitHub issue form.
6+
* -t|--template-filepath The filepath for the GitHub issue form YAML template.
7+
-h|--help Shows help text.

GitHubIssueFormsParser/tests/GitHubIssuesParserCli.Tests/TestFiles/CliOutputUsage.txt renamed to GitHubIssueFormsParser/tests/GitHubIssuesParserCli.Tests/TestFiles/CliOutputUsage-windows.txt

File renamed without changes.

0 commit comments

Comments
 (0)