Skip to content

Commit

Permalink
refactor: Clean up some imports and miscellaneous (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
adriansberg authored Oct 7, 2024
1 parent eb25a6a commit f8907d5
Show file tree
Hide file tree
Showing 11 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"sdk": {
"version": "8.0.201",
"rollForward": "latestPatch",
"rollForward": "latestFeature",
"allowPrerelease": true
}
}
4 changes: 1 addition & 3 deletions src/Api/Routes/Weather/Endpoints/DeleteWeather.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Api.Routes.Weather.Models;
using Application.Weather.AddForecast;
using Application.Weather.DeleteForecast;
using MediatR;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;

namespace Api.Routes.Weather.Endpoints;

Expand Down
1 change: 0 additions & 1 deletion src/Api/Routes/Weather/Endpoints/GetWeather.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Application.Weather.GetForecast;
using MediatR;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;

namespace Api.Routes.Weather.Endpoints;

Expand Down
1 change: 0 additions & 1 deletion src/Api/Routes/Weather/WeatherAdminGroup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Api.Authorization;
using Api.Routes.Weather.Endpoints;

namespace Api.Routes.Weather;
Expand Down
5 changes: 4 additions & 1 deletion src/Api/setup-jwts.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
dotnet user-jwts clear
# Warning: This will clear all JWT tokens that already exists!
dotnet user-jwts clear --force

# Create JWT token with the "write" and "read" scopes
dotnet user-jwts create --audience weather.dev.api --scope "write" --scope "read"
# Create JWT token with the "admin" scope
dotnet user-jwts create --audience weather.dev.api --scope "admin"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using FluentResults;
using MediatR;

namespace Application.Weather.AddForecast;
namespace Application.Weather.DeleteForecast;

public record DeleteForecastCommand(DateOnly Date) : IRequest<Result>;
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using Domain;
using FluentResults;
using MediatR;

namespace Application.Weather.AddForecast;
namespace Application.Weather.DeleteForecast;

internal class DeleteForecastCommandHandler(IWeatherRepository weatherRepository, IUnitOfWork unitOfWork)
: IRequestHandler<DeleteForecastCommand, Result>
Expand Down
2 changes: 1 addition & 1 deletion src/Infrastructure/Repositories/WeatherRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public class WeatherRepository(DatabaseContext context) : IWeatherRepository

public async Task AddForecastAsync(Forecast forecast)
{
context.Forecasts.Add(forecast);
await context.Forecasts.AddAsync(forecast);
}
}
1 change: 0 additions & 1 deletion src/Infrastructure/TestContainers/TestContainersFactory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using Testcontainers.PostgreSql;

Expand Down
1 change: 1 addition & 0 deletions tests/Api.E2E/ForecastTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public async Task DeleteForecast_AsAdmin_ShouldReturnNoContent()
dbForecast.IsDeleted.Should().BeTrue();

Check warning on line 163 in tests/Api.E2E/ForecastTests.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Dereference of a possibly null reference.

Check warning on line 163 in tests/Api.E2E/ForecastTests.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Dereference of a possibly null reference.
}

[Fact]
public async Task DeleteForecast_AsUser_ShouldReturnForbidden()
{
// Arrange
Expand Down
2 changes: 0 additions & 2 deletions tests/Api.E2E/Shared/ApiFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.AspNetCore.TestHost;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
Expand All @@ -17,7 +16,6 @@
using Npgsql;
using Respawn;
using Respawn.Graph;
using Testcontainers.PostgreSql;

namespace Api.E2E.Shared;

Expand Down

0 comments on commit f8907d5

Please sign in to comment.