using Microsoft.Extensions.Configuration; using Newsbot.Collector.Domain.Consts; using Newsbot.Collector.Domain.Entities; using Newsbot.Collector.Domain.Models; using Newsbot.Collector.Domain.Models.Config; using Newsbot.Collector.Services.Jobs; namespace Newsbot.Collector.Tests.Jobs; public class CodeProjectWatcherJobTests { [Fact] public void CanReturnReleases() { var client = new CodeProjectWatcherJob(new CodeProjectWatcherJobOptions { ConnectionStrings = TestHelper.LoadConfig().GetSection(ConfigConst.SectionConnectionStrings) .Get(), FeaturePullCommits = true, FeaturePullReleases = true }); var results = client.CheckForReleases(new SourceEntity { Id = Guid.NewGuid(), Url = "https://github.com/jtom38/dvb", Type = SourceTypes.CodeProject, Site = SourceTypes.CodeProject, Name = "jtom38/dvb", Source = "feed", Enabled = true }); if (!results.Any()) { Assert.Fail("Expected at least one item"); } } [Fact] public void CollectsTagsButNoReleases() { var client = new CodeProjectWatcherJob(new CodeProjectWatcherJobOptions { ConnectionStrings = TestHelper.LoadConfig().GetSection(ConfigConst.SectionConnectionStrings) .Get(), FeaturePullCommits = true, FeaturePullReleases = true }); var results = client.CheckForReleases(new SourceEntity { Id = Guid.NewGuid(), Url = "https://github.com/python/cpython", Type = SourceTypes.CodeProject, Site = SourceTypes.CodeProject, Name = "python.cpython", Source = "feed", Enabled = true }); if (!results.Any()) { Assert.Fail("Expected at least one item"); } } [Fact] public void CollectsCommits() { var client = new CodeProjectWatcherJob(new CodeProjectWatcherJobOptions { ConnectionStrings = TestHelper.LoadConfig().GetSection(ConfigConst.SectionConnectionStrings) .Get(), FeaturePullCommits = true, FeaturePullReleases = true }); var results = client.CheckForCommits(new SourceEntity { Id = Guid.NewGuid(), Url = "https://github.com/jtom38/dvb", Type = SourceTypes.CodeProject, Site = SourceTypes.CodeProject, Name = "jtom38/dvb", Source = "feed", Enabled = true }); if (!results.Any()) { Assert.Fail("Expected at least one item"); } } }