Skip to content

Commit 848b334

Browse files
Ignore fonts from comparison as they contain metadata which can change on generation
1 parent f4076af commit 848b334

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

src/Pdf2Html/Controllers/RootController.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public RootController(ILogger<RootController> logger)
1616
_logger = logger;
1717
}
1818

19-
2019
[HttpGet]
2120
public ActionResult Get()
2221
{
@@ -38,7 +37,6 @@ public async Task<ActionResult> Post()
3837
await using (var tempFileStream = System.IO.File.Open(inputFile, FileMode.Truncate))
3938
{
4039
await Request.Body.CopyToAsync(tempFileStream);
41-
await tempFileStream.FlushAsync();
4240
_logger.LogInformation($"Copied {FormatToMb(new FileInfo(inputFile).Length)} to {inputFile}");
4341
}
4442

tests/E2E.Tests/RootControllerTest.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
using System.Net;
2+
using System.Text.RegularExpressions;
23

34
namespace E2E.Tests;
45

5-
public class ConvertPdfTest
6+
public partial class ConvertPdfTest
67
{
8+
[GeneratedRegex("^@font-face{.*$", RegexOptions.Multiline)]
9+
private static partial Regex FontFaceRegex();
10+
711
private HttpClient _client = null!;
812

913
[SetUp]
@@ -33,9 +37,13 @@ public async Task TestConvertPdf()
3337
Assert.Multiple(async () =>
3438
{
3539
var responseStream = await response.Content.ReadAsStreamAsync();
40+
var content = await new StreamReader(responseStream).ReadToEndAsync();
3641
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK),
37-
() => $"Conversion failed: {new StreamReader(responseStream).ReadToEnd()}");
38-
Assert.That(responseStream, Is.EqualTo(GetResourceStream("CS_cheat_sheet.html")));
42+
() => $"Conversion failed: {content}");
43+
var expected = await new StreamReader(GetResourceStream("CS_cheat_sheet.html")).ReadToEndAsync();
44+
45+
string RemoveFonts(string input) => FontFaceRegex().Replace(input, "");
46+
Assert.That(RemoveFonts(content), Is.EqualTo(RemoveFonts(expected)));
3947
});
4048
}
4149

0 commit comments

Comments
 (0)