Skip to content

Commit

Permalink
Fixed more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Drew MORGAN authored and Drew MORGAN committed Feb 27, 2025
1 parent 66079cc commit 5fc5dfc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Dfe.PlanTech.Web/Controllers/PagesController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Diagnostics;
using Dfe.PlanTech.Application.Constants;
using Dfe.PlanTech.Application.Exceptions;
using Dfe.PlanTech.Domain.Content.Interfaces;
using Dfe.PlanTech.Domain.Content.Models;
using Dfe.PlanTech.Domain.Users.Interfaces;
Expand All @@ -11,6 +12,7 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using static Microsoft.ApplicationInsights.MetricDimensionNames.TelemetryContext;

namespace Dfe.PlanTech.Web.Controllers;

Expand All @@ -33,7 +35,7 @@ public async Task<IActionResult> GetByRoute([ModelBinder(typeof(PageModelBinder)
if (page == null)
{
logger.LogInformation("Could not find page at {Path}", Request.Path.Value);
return await NotFoundError();
throw new ContentfulDataUnavailableException($"Could not find page at {Request.Path.Value}");
}

var viewModel = new PageViewModel(page, this, user, Logger);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Security.Claims;
using Dfe.PlanTech.Application.Exceptions;
using Dfe.PlanTech.Domain.Content.Interfaces;
using Dfe.PlanTech.Domain.Content.Models;
using Dfe.PlanTech.Domain.Cookie;
Expand Down Expand Up @@ -272,9 +273,9 @@ public async Task Should_ReturnNotFoundError_Page_When_Page_Is_Null()

userSubstitute.GetOrganisationData().Returns(establishment);

var result = await _controller.GetByRoute(null, userSubstitute) as ViewResult;
var action = async () => await _controller.GetByRoute(null, userSubstitute);

Assert.NotNull(result);
await Assert.ThrowsAsync<ContentfulDataUnavailableException>(action);
}

[Fact]
Expand Down

0 comments on commit 5fc5dfc

Please sign in to comment.