public async Task NoUpdateSubscriptionBecauseNotEnabled() { var channel = new Channel { Name = "channel", Classification = "class" }; var oldBuild = new Build { Branch = "source.branch", Repository = "source.repo", BuildNumber = "old.build.number", Commit = "oldSha", DateProduced = DateTimeOffset.UtcNow.AddDays(-2) }; var location = "https://source.feed/index.json"; var build = new Build { Branch = "source.branch", Repository = "source.repo", BuildNumber = "build.number", Commit = "sha", DateProduced = DateTimeOffset.UtcNow, Assets = new List <Asset> { new Asset { Name = "source.asset", Version = "1.0.1", Locations = new List <AssetLocation> { new AssetLocation { Location = location, Type = LocationType.NugetFeed } } } } }; var buildChannel = new BuildChannel { Build = build, Channel = channel }; var subscription = new Subscription { Channel = channel, SourceRepository = "source.repo", TargetRepository = "target.repo", TargetBranch = "target.branch", Enabled = false, PolicyObject = new SubscriptionPolicy { MergePolicies = null, UpdateFrequency = UpdateFrequency.EveryDay }, LastAppliedBuild = oldBuild }; var repoInstallation = new Repository { RepositoryName = "target.repo", InstallationId = 1 }; await Context.Repositories.AddAsync(repoInstallation); await Context.Subscriptions.AddAsync(subscription); await Context.BuildChannels.AddAsync(buildChannel); await Context.SaveChangesAsync(); SubscriptionActor.Verify(a => a.UpdateAsync(build.Id), Times.Never()); var updater = ActivatorUtilities.CreateInstance <DependencyUpdater>(Scope.ServiceProvider); await updater.CheckSubscriptionsAsync(CancellationToken.None); }
public async Task EveryBuildSubscriptionNotEnabled() { var channel = new Channel { Name = "channel", Classification = "class" }; var build = new Build { AzureDevOpsBranch = "source.branch", AzureDevOpsRepository = "source.repo", AzureDevOpsBuildNumber = "build.number", Commit = "sha", DateProduced = DateTimeOffset.UtcNow.AddDays(-1) }; var location = "https://repo.feed/index.json"; var newAsset = new Asset { Name = "source.asset", Version = "1.0.1", NonShipping = false, Locations = new List <AssetLocation> { new AssetLocation { Location = location, Type = LocationType.NugetFeed } } }; var newBuild = new Build { AzureDevOpsBranch = "source.branch", AzureDevOpsRepository = "source.repo", AzureDevOpsBuildNumber = "build.number.2", Commit = "sha2", DateProduced = DateTimeOffset.UtcNow, Assets = new List <Asset> { newAsset } }; var buildChannels = new[] { new BuildChannel { Build = build, Channel = channel }, new BuildChannel { Build = newBuild, Channel = channel } }; var subscription = new Subscription { Channel = channel, SourceRepository = "source.repo", TargetRepository = "target.repo", TargetBranch = "target.branch", Enabled = false, PolicyObject = new SubscriptionPolicy { MergePolicies = null, UpdateFrequency = UpdateFrequency.EveryBuild }, LastAppliedBuild = build }; var repoInstallation = new Repository { RepositoryName = "target.repo", InstallationId = 1 }; await Context.BuildChannels.AddRangeAsync(buildChannels); await Context.Subscriptions.AddAsync(subscription); await Context.Repositories.AddAsync(repoInstallation); await Context.SaveChangesAsync(); SubscriptionActor.Verify(a => a.UpdateAsync(build.Id), Times.Never()); var updater = ActivatorUtilities.CreateInstance <DependencyUpdater>(Scope.ServiceProvider); await updater.UpdateDependenciesAsync(newBuild.Id, channel.Id); }