2023-03-11 10:43:06 -08:00
|
|
|
using Microsoft.Extensions.Configuration;
|
2023-03-31 22:49:39 -07:00
|
|
|
using Newsbot.Collector.Domain.Models;
|
|
|
|
using Newsbot.Collector.Domain.Models.Config;
|
2023-03-11 10:43:06 -08:00
|
|
|
using Newsbot.Collector.Services.Jobs;
|
|
|
|
|
|
|
|
namespace Newsbot.Collector.Tests.Jobs;
|
|
|
|
|
|
|
|
public class GithubWatcherJobTests
|
|
|
|
{
|
|
|
|
private IConfiguration GetConfiguration()
|
|
|
|
{
|
2023-03-31 22:49:39 -07:00
|
|
|
var inMemorySettings = new Dictionary<string, string>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"ConnectionStrings:database",
|
|
|
|
"Host=localhost;Username=postgres;Password=postgres;Database=postgres;sslmode=disable"
|
|
|
|
}
|
2023-03-11 10:43:06 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
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 CanPullAFeed()
|
|
|
|
{
|
|
|
|
var client = new GithubWatcherJob();
|
2023-03-31 22:49:39 -07:00
|
|
|
client.InitAndExecute(new GithubWatcherJobOptions
|
2023-03-11 10:43:06 -08:00
|
|
|
{
|
2023-03-31 22:49:39 -07:00
|
|
|
ConnectionStrings = new ConfigSectionConnectionStrings
|
|
|
|
{
|
|
|
|
Database = ConnectionString()
|
|
|
|
},
|
2023-03-11 10:43:06 -08:00
|
|
|
FeaturePullCommits = true,
|
|
|
|
FeaturePullReleases = true
|
|
|
|
});
|
|
|
|
client.Collect(new Uri("https://github.com/jtom38/dvb"));
|
|
|
|
}
|
|
|
|
}
|