James Tombleson
9be985da0a
* Found the meta tags on youtube... in the body and updated the client to pull them out. * Updated namespace on test * I think formatting cleaned this up * Seed migrations have been cleaned up to get my configs out and moving them to a script. * Updates to the ISourcesRepository.cs to allow for new calls to the db. * formatter * Db models updated. Icon now can track sourceID and source can have a youtube id. * Updated api logger to ignore otel if no connection string given. * updated docker init so I can run migrations from the image * seed was updated to reflect the new api changes * Updated the SourcesController.cs to grab icon data. * Added reddit const values * Minor changes to HtmlPageReader.cs * Jobs are now pulling in the config section to bundle values. * Removed youtube api, not needed anymore. * test updates
75 lines
2.1 KiB
C#
75 lines
2.1 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using Newsbot.Collector.Domain.Models.Config;
|
|
using Newsbot.Collector.Services.Jobs;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Newsbot.Collector.Tests.Jobs;
|
|
|
|
public class RssWatcherJobTest
|
|
{
|
|
private readonly ITestOutputHelper _testOutputHelper;
|
|
|
|
public RssWatcherJobTest(ITestOutputHelper testOutputHelper)
|
|
{
|
|
_testOutputHelper = testOutputHelper;
|
|
}
|
|
|
|
private IConfiguration GetConfiguration()
|
|
{
|
|
var inMemorySettings = new Dictionary<string, string>
|
|
{
|
|
{
|
|
"ConnectionStrings:database",
|
|
"Host=localhost;Username=postgres;Password=postgres;Database=postgres;sslmode=disable"
|
|
}
|
|
};
|
|
|
|
IConfiguration configuration = new ConfigurationBuilder()
|
|
.AddInMemoryCollection(inMemorySettings)
|
|
.Build();
|
|
return configuration;
|
|
}
|
|
|
|
private string ConnectionString()
|
|
{
|
|
return "Host=localhost;Username=postgres;Password=postgres;Database=postgres;sslmode=disable";
|
|
}
|
|
|
|
[Fact]
|
|
public void CanFindItemsNoDb()
|
|
{
|
|
const string url = "https://www.engadget.com/rss.xml";
|
|
var client = new RssWatcherJob();
|
|
client.Collect(url, Guid.NewGuid(), 0);
|
|
}
|
|
|
|
[Fact]
|
|
public void CanAddItemsToDb()
|
|
{
|
|
var url = "https://www.engadget.com/rss.xml";
|
|
var client = new RssWatcherJob();
|
|
client.InitAndExecute(new RssWatcherJobOptions
|
|
{
|
|
ConnectionStrings = new ConfigSectionConnectionStrings
|
|
{
|
|
Database = ConnectionString()
|
|
}
|
|
});
|
|
var items = client.Collect(url, Guid.NewGuid(), 0);
|
|
client.UpdateDatabase(items);
|
|
}
|
|
|
|
[Fact]
|
|
public void CanReadHtmlDrivenFeedPage()
|
|
{
|
|
var url = "https://www.howtogeek.com/feed/";
|
|
var client = new RssWatcherJob();
|
|
client.InitAndExecute(new RssWatcherJobOptions
|
|
{
|
|
ConnectionStrings = new ConfigSectionConnectionStrings
|
|
{
|
|
Database = ConnectionString()
|
|
}
|
|
});
|
|
}
|
|
} |