File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ on :
2+ push :
3+ branches :
4+ - " main"
5+ pull_request :
6+ branches :
7+ - " main"
8+
9+ env :
10+ TEST_TAG : corefiling/pdf2html:test
11+
12+ jobs :
13+ docker :
14+ runs-on : ubuntu-latest
15+ steps :
16+ - name : Checkout
17+ uses : actions/checkout@v3
18+ with :
19+ lfs : true
20+ - name : Set up QEMU
21+ uses : docker/setup-qemu-action@v2
22+ - name : Set up Docker Buildx
23+ uses : docker/setup-buildx-action@v2
24+ - name : Build and export to Docker
25+ uses : docker/build-push-action@v4
26+ with :
27+ context : ./src/Pdf2Html
28+ load : true
29+ tags : ${{ env.TEST_TAG }}
30+ - name : Set up dotnet
31+ uses : actions/setup-dotnet@v3
32+ with :
33+ dotnet-version : " 7.x"
34+ - name : E2E tests
35+ run : |
36+ docker run --rm --detach -p 8080:8080 --name pdf2html ${{ env.TEST_TAG }}
37+ dotnet test --filter "FullyQualifiedName=E2E.Tests"
38+ docker stop pdf2html
Original file line number Diff line number Diff line change @@ -16,7 +16,6 @@ public RootController(ILogger<RootController> logger)
1616 _logger = logger ;
1717 }
1818
19-
2019 [ HttpGet ]
2120 public ActionResult Get ( )
2221 {
Original file line number Diff line number Diff line change @@ -15,4 +15,4 @@ WORKDIR /app
1515COPY --from=build /app ./
1616ENV ASPNETCORE_URLS=http://+:8080
1717EXPOSE 8080
18- CMD ["./pdf2html " ]
18+ CMD ["./Pdf2Html " ]
Original file line number Diff line number Diff line change 55 <Nullable >enable</Nullable >
66 <ImplicitUsings >enable</ImplicitUsings >
77 <Version >1.0.0</Version >
8- <AssemblyName >Pdf2html </AssemblyName >
9- <RootNamespace >Pdf2html </RootNamespace >
8+ <AssemblyName >Pdf2Html </AssemblyName >
9+ <RootNamespace >Pdf2Html </RootNamespace >
1010 </PropertyGroup >
1111
1212 <ItemGroup >
Original file line number Diff line number Diff line change 11using System . Net ;
2+ using System . Text . RegularExpressions ;
23
34namespace 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 ]
@@ -32,8 +36,14 @@ public async Task TestConvertPdf()
3236 var response = await _client . PostAsync ( "/" , new StreamContent ( GetResourceStream ( "CS_cheat_sheet.pdf" ) ) ) ;
3337 Assert . Multiple ( async ( ) =>
3438 {
35- Assert . That ( response . StatusCode , Is . EqualTo ( HttpStatusCode . OK ) ) ;
36- Assert . That ( await response . Content . ReadAsStreamAsync ( ) , Is . EqualTo ( GetResourceStream ( "CS_cheat_sheet.html" ) ) ) ;
39+ var responseStream = await response . Content . ReadAsStreamAsync ( ) ;
40+ var content = await new StreamReader ( responseStream ) . ReadToEndAsync ( ) ;
41+ Assert . That ( response . StatusCode , Is . EqualTo ( HttpStatusCode . OK ) ,
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 ) ) ) ;
3747 } ) ;
3848 }
3949
You can’t perform that action at this time.
0 commit comments