Article controller was updated and tests updated
All checks were successful
continuous-integration/drone/pr Build is passing
All checks were successful
continuous-integration/drone/pr Build is passing
This commit is contained in:
parent
751bbd3a7b
commit
a3085bb27f
@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newsbot.Collector.Domain.Dto;
|
||||
using Newsbot.Collector.Domain.Entities;
|
||||
using Newsbot.Collector.Domain.Interfaces;
|
||||
using Newsbot.Collector.Domain.Results;
|
||||
|
||||
@ -15,11 +16,13 @@ public class ArticlesController : ControllerBase
|
||||
//private readonly ILogger<ArticlesController> _logger;
|
||||
private readonly IArticlesRepository _articles;
|
||||
private readonly ISourcesRepository _sources;
|
||||
private readonly IAuthorTable _author;
|
||||
|
||||
public ArticlesController(IArticlesRepository articles, ISourcesRepository sources)
|
||||
public ArticlesController(IArticlesRepository articles, ISourcesRepository sources, IAuthorTable author)
|
||||
{
|
||||
_articles = articles;
|
||||
_sources = sources;
|
||||
_author = author;
|
||||
}
|
||||
|
||||
[HttpGet(Name = "GetArticles")]
|
||||
@ -59,11 +62,13 @@ public class ArticlesController : ControllerBase
|
||||
{
|
||||
var item = _articles.GetById(id);
|
||||
var sourceItem = _sources.GetById(item.SourceId);
|
||||
var author = _author.GetBySourceIdAndNameAsync(sourceItem.Id, sourceItem.Name);
|
||||
author.Wait();
|
||||
|
||||
return new OkObjectResult(new ArticleDetailsResult
|
||||
{
|
||||
IsSuccessful = true,
|
||||
Item = ArticleDetailsDto.Convert(item, sourceItem)
|
||||
Item = ArticleDetailsDto.Convert(item, sourceItem, author.Result)
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -32,12 +32,15 @@ public class DiscordNotificationJobTest
|
||||
PubDate = DateTime.Now,
|
||||
Thumbnail = "https://cdn.arstechnica.net/wp-content/uploads/2023/03/GettyImages-944827400-800x534.jpg",
|
||||
Description = "Please work",
|
||||
AuthorName = "No one knows"
|
||||
},
|
||||
new IconEntity()
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
FileName = "https://www.redditstatic.com/desktop2x/img/favicon/android-icon-192x192.png"
|
||||
}, new AuthorEntity
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Name = "test"
|
||||
});
|
||||
webhookClient.SendMessage(msg);
|
||||
}
|
||||
@ -59,7 +62,6 @@ public class DiscordNotificationJobTest
|
||||
Thumbnail =
|
||||
"https://cdn.arstechnica.net/wp-content/uploads/2023/03/GettyImages-944827400-800x534.jpg",
|
||||
Description = "Please work",
|
||||
AuthorName = "No one knows",
|
||||
CodeIsCommit = true
|
||||
},
|
||||
new SourceEntity
|
||||
@ -82,6 +84,9 @@ public class DiscordNotificationJobTest
|
||||
{
|
||||
CodeAllowCommits = false,
|
||||
CodeAllowReleases = true
|
||||
}, new AuthorEntity
|
||||
{
|
||||
Name = "a"
|
||||
});
|
||||
Assert.Fail("Expected a error to come back.");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user