Exemplo n.º 1
0
        private IDisposable WithExistingPullRequest(SynchronizePullRequestResult checkResult)
        {
            AfterDbUpdateActions.Add(() =>
            {
                var pr = new InProgressPullRequest
                {
                    Url = InProgressPrUrl,
                    ContainedSubscriptions = new List <SubscriptionPullRequestUpdate>
                    {
                        new SubscriptionPullRequestUpdate
                        {
                            BuildId        = -1,
                            SubscriptionId = Subscription.Id
                        }
                    },
                    RequiredUpdates = new List <DependencyUpdateSummary>
                    {
                        new DependencyUpdateSummary
                        {
                            DependencyName = "Ham",
                            FromVersion    = "1.0.0-beta.1",
                            ToVersion      = "1.0.1-beta.1"
                        },
                        new DependencyUpdateSummary
                        {
                            DependencyName = "Ham",
                            FromVersion    = "1.0.0-beta.1",
                            ToVersion      = "1.0.1-beta.1"
                        },
                    }
                };
                StateManager.SetStateAsync(PullRequestActorImplementation.PullRequest, pr);
                ExpectedActorState.Add(PullRequestActorImplementation.PullRequest, pr);
            });

            ActionRunner.Setup(r => r.ExecuteAction(It.IsAny <Expression <Func <Task <ActionResult <SynchronizePullRequestResult> > > > >()))
            .ReturnsAsync(checkResult);

            if (checkResult == SynchronizePullRequestResult.InProgressCanUpdate)
            {
                DarcRemotes.GetOrAddValue(TargetRepo, CreateMock <IRemote>)
                .Setup(r => r.GetPullRequestAsync(InProgressPrUrl))
                .ReturnsAsync(
                    new PullRequest
                {
                    HeadBranch = InProgressPrHeadBranch,
                    BaseBranch = TargetBranch
                });
            }

            return(Disposable.Create(
                       () =>
            {
                ActionRunner.Verify(r => r.ExecuteAction(It.IsAny <Expression <Func <Task <ActionResult <SynchronizePullRequestResult> > > > >()));
                if (checkResult == SynchronizePullRequestResult.InProgressCanUpdate)
                {
                    DarcRemotes[TargetRepo].Verify(r => r.GetPullRequestAsync(InProgressPrUrl));
                }
            }));
        }
Exemplo n.º 2
0
 private void AndShouldHaveInProgressPullRequestState(Build forBuild)
 {
     ExpectedActorState.Add(
         PullRequestActorImplementation.PullRequest,
         new InProgressPullRequest
     {
         ContainedSubscriptions = new List <SubscriptionPullRequestUpdate>
         {
             new SubscriptionPullRequestUpdate
             {
                 BuildId        = forBuild.Id,
                 SubscriptionId = Subscription.Id
             }
         },
         RequiredUpdates = forBuild.Assets.Select(
             d => new DependencyUpdateSummary
         {
             DependencyName = d.Name,
             FromVersion    = d.Version,
             ToVersion      = d.Version
         })
                           .ToList(),
         Url = PrUrl
     });
 }
 private void AndShouldHaveInProgressPullRequestState(Build forBuild)
 {
     ExpectedActorState.Add(
         PullRequestActorImplementation.PullRequest,
         new InProgressPullRequest
     {
         ContainedSubscriptions = new List <SubscriptionPullRequestUpdate>
         {
             new SubscriptionPullRequestUpdate
             {
                 BuildId        = forBuild.Id,
                 SubscriptionId = Subscription.Id
             }
         },
         Url = PrUrl
     });
 }
        private IDisposable WithExistingPullRequest(bool updatable)
        {
            var pr = new InProgressPullRequest
            {
                Url = InProgressPrUrl,
                ContainedSubscriptions = new List <SubscriptionPullRequestUpdate>
                {
                    new SubscriptionPullRequestUpdate
                    {
                        BuildId        = -1,
                        SubscriptionId = Subscription.Id
                    }
                }
            };

            StateManager.SetStateAsync(PullRequestActorImplementation.PullRequest, pr);
            ExpectedActorState.Add(PullRequestActorImplementation.PullRequest, pr);

            ActionRunner.Setup(r => r.ExecuteAction(It.IsAny <Expression <Func <Task <ActionResult <bool?> > > > >()))
            .ReturnsAsync(updatable);

            if (updatable)
            {
                DarcRemotes.GetOrAddValue(TargetRepo, CreateMock <IRemote>)
                .Setup(r => r.GetPullRequestAsync(InProgressPrUrl))
                .ReturnsAsync(
                    new PullRequest
                {
                    HeadBranch = InProgressPrHeadBranch,
                    BaseBranch = TargetBranch
                });
            }

            return(Disposable.Create(
                       () =>
            {
                ActionRunner.Verify(r => r.ExecuteAction(It.IsAny <Expression <Func <Task <ActionResult <bool?> > > > >()));
                if (updatable)
                {
                    DarcRemotes[TargetRepo].Verify(r => r.GetPullRequestAsync(InProgressPrUrl));
                }
            }));
        }
 private void AndShouldHavePendingUpdateState(Build forBuild)
 {
     ExpectedActorState.Add(
         PullRequestActorImplementation.PullRequestUpdate,
         new List <PullRequestActorImplementation.UpdateAssetsParameters>
     {
         new PullRequestActorImplementation.UpdateAssetsParameters
         {
             SubscriptionId = Subscription.Id,
             BuildId        = forBuild.Id,
             SourceSha      = forBuild.Commit,
             SourceRepo     = forBuild.GitHubRepository ?? forBuild.AzureDevOpsRepository,
             Assets         = forBuild.Assets.Select(
                 a => new Asset
             {
                 Name    = a.Name,
                 Version = a.Version
             })
                              .ToList(),
             IsCoherencyUpdate = false
         }
     });
 }