-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
147 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,32 @@ jobs: | |
- uses: actions/checkout@v2 | ||
- name: Run build | ||
run: docker build . --file ./OpenAlprWebhookProcessor/Dockerfile | ||
|
||
back-end-tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Run backend tests | ||
run: dotnet test --configuration Release --no-build --collect:"XPlat Code Coverage" --results-directory ./coverage | ||
- name: Code Coverage Report | ||
uses: irongut/[email protected] | ||
with: | ||
filename: coverage/**/coverage.cobertura.xml | ||
badge: true | ||
fail_below_min: true | ||
format: markdown | ||
hide_branch_rate: false | ||
hide_complexity: true | ||
indicators: true | ||
output: both | ||
thresholds: '60 80' | ||
|
||
- name: Add Coverage PR Comment | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
if: github.event_name == 'pull_request' | ||
with: | ||
recreate: true | ||
path: code-coverage-results.md | ||
|
||
front-end-tests: | ||
runs-on: ubuntu-latest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using Microsoft.Data.Sqlite; | ||
using Microsoft.EntityFrameworkCore; | ||
using OpenAlprWebhookProcessor.Data; | ||
using OpenAlprWebhookProcessor.Settings; | ||
|
||
namespace Tests | ||
{ | ||
public class AgentTests | ||
{ | ||
private EfContextCreator _contextCreator; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
_contextCreator = new EfContextCreator(); | ||
} | ||
|
||
[Test] | ||
public async Task AgentRequestSucceeds() | ||
{ | ||
using (var processorContext = _contextCreator.CreateContext()) | ||
{ | ||
if (processorContext.Database.EnsureCreated()) | ||
{ | ||
processorContext.Agents.Add(new OpenAlprWebhookProcessor.Data.Agent() | ||
{ | ||
EndpointUrl = "http://google.com", | ||
Hostname = "localhost", | ||
Id = Guid.NewGuid(), | ||
IsDebugEnabled = true, | ||
IsImageCompressionEnabled = true, | ||
LastHeartbeatEpochMs = 0, | ||
LastSuccessfulScrapeEpoch = 0, | ||
Latitude = 0, | ||
Longitude = 0, | ||
NextScrapeEpochMs = 0, | ||
OpenAlprWebServerApiKey = null, | ||
OpenAlprWebServerUrl = null, | ||
ScheduledScrapingIntervalMinutes = 0, | ||
SunriseOffset = 0, | ||
SunsetOffset = 0, | ||
TimeZoneOffset = 0, | ||
Uid = null, | ||
Version = null, | ||
}); | ||
|
||
await processorContext.SaveChangesAsync(); | ||
var handler = new GetAgentRequestHandler(processorContext); | ||
|
||
var agentResult = await handler.HandleAsync(default); | ||
|
||
Assert.That(agentResult, Is.Not.Null); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Microsoft.Data.Sqlite; | ||
using Microsoft.EntityFrameworkCore; | ||
using OpenAlprWebhookProcessor.Data; | ||
|
||
namespace Tests | ||
{ | ||
public class EfContextCreator | ||
{ | ||
readonly SqliteConnection _connection; | ||
|
||
readonly DbContextOptions<ProcessorContext> _contextOptions; | ||
|
||
public EfContextCreator() | ||
{ | ||
_connection = new SqliteConnection("Filename=:memory:"); | ||
_connection.Open(); | ||
|
||
_contextOptions = new DbContextOptionsBuilder<ProcessorContext>() | ||
.UseSqlite(_connection) | ||
.Options; | ||
|
||
using var context = new ProcessorContext(_contextOptions); | ||
|
||
context.Database.EnsureCreated(); | ||
} | ||
|
||
public ProcessorContext CreateContext() => new(_contextOptions); | ||
|
||
public void Dispose() => _connection.Dispose(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
global using NUnit.Framework; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.1" /> | ||
<PackageReference Include="NUnit" Version="3.13.3" /> | ||
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" /> | ||
<PackageReference Include="NUnit.Analyzers" Version="3.6.1" /> | ||
<PackageReference Include="coverlet.collector" Version="3.2.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\OpenAlprWebhookProcessor\OpenAlprWebhookProcessor.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |