public Checkout ( ILocalRepositoryModel repository, IPullRequestModel pullRequest, string localBranchName ) : IObservable |
||
repository | ILocalRepositoryModel | |
pullRequest | IPullRequestModel | |
localBranchName | string | |
Résultat | IObservable |
public async void ShouldCheckoutExistingBranch() { var gitClient = Substitute.For<IGitClient>(); var service = new PullRequestService( gitClient, MockGitService(), Substitute.For<IOperatingSystem>(), Substitute.For<IUsageTracker>()); var localRepo = Substitute.For<ILocalRepositoryModel>(); var pr = Substitute.For<IPullRequestModel>(); await service.Checkout(localRepo, pr, "pr/123-foo1"); gitClient.Received().Checkout(Arg.Any<IRepository>(), "pr/123-foo1").Forget(); Assert.Equal(1, gitClient.ReceivedCalls().Count()); }
public async void ShouldCheckoutLocalBranch() { var gitClient = Substitute.For<IGitClient>(); var service = new PullRequestService( gitClient, MockGitService(), Substitute.For<IOperatingSystem>(), Substitute.For<IUsageTracker>()); var localRepo = Substitute.For<ILocalRepositoryModel>(); localRepo.CloneUrl.Returns(new UriString("https://foo.bar/owner/repo")); var pr = Substitute.For<IPullRequestModel>(); pr.Number.Returns(5); pr.Head.Returns(new GitReferenceModel("source", "owner:local", "123", "https://foo.bar/owner/repo")); await service.Checkout(localRepo, pr, "local"); gitClient.Received().Fetch(Arg.Any<IRepository>(), "origin").Forget(); gitClient.Received().Checkout(Arg.Any<IRepository>(), "local").Forget(); Assert.Equal(2, gitClient.ReceivedCalls().Count()); }
public async void ShouldUseUniquelyNamedRemoteForFork() { var gitClient = Substitute.For<IGitClient>(); var gitService = MockGitService(); var service = new PullRequestService( gitClient, gitService, Substitute.For<IOperatingSystem>(), Substitute.For<IUsageTracker>()); var localRepo = Substitute.For<ILocalRepositoryModel>(); localRepo.CloneUrl.Returns(new UriString("https://foo.bar/owner/repo")); var repo = gitService.GetRepository(localRepo.CloneUrl); var remote = Substitute.For<Remote>(); var remoteCollection = Substitute.For<RemoteCollection>(); remoteCollection["fork"].Returns(remote); repo.Network.Remotes.Returns(remoteCollection); var pr = Substitute.For<IPullRequestModel>(); pr.Number.Returns(5); pr.Head.Returns(new GitReferenceModel("source", "owner:local", "123", "https://foo.bar/fork/repo.git")); await service.Checkout(localRepo, pr, "pr/5-fork-branch"); gitClient.Received().SetRemote(Arg.Any<IRepository>(), "fork1", new Uri("https://foo.bar/fork/repo.git")).Forget(); gitClient.Received().SetConfig(Arg.Any<IRepository>(), "remote.fork1.created-by-ghfvs", "true").Forget(); }
public async void ShouldCheckoutBranchFromFork() { var gitClient = Substitute.For<IGitClient>(); var service = new PullRequestService( gitClient, MockGitService(), Substitute.For<IOperatingSystem>(), Substitute.For<IUsageTracker>()); var localRepo = Substitute.For<ILocalRepositoryModel>(); localRepo.CloneUrl.Returns(new UriString("https://foo.bar/owner/repo")); var pr = Substitute.For<IPullRequestModel>(); pr.Number.Returns(5); pr.Head.Returns(new GitReferenceModel("source", "owner:local", "123", "https://foo.bar/fork/repo.git")); await service.Checkout(localRepo, pr, "pr/5-fork-branch"); gitClient.Received().SetRemote(Arg.Any<IRepository>(), "fork", new Uri("https://foo.bar/fork/repo.git")).Forget(); gitClient.Received().SetConfig(Arg.Any<IRepository>(), "remote.fork.created-by-ghfvs", "true").Forget(); gitClient.Received().Fetch(Arg.Any<IRepository>(), "fork").Forget(); gitClient.Received().Fetch(Arg.Any<IRepository>(), "fork", "source:pr/5-fork-branch").Forget(); gitClient.Received().Checkout(Arg.Any<IRepository>(), "pr/5-fork-branch").Forget(); gitClient.Received().SetTrackingBranch(Arg.Any<IRepository>(), "pr/5-fork-branch", "refs/remotes/fork/source").Forget(); gitClient.Received().SetConfig(Arg.Any<IRepository>(), "branch.pr/5-fork-branch.ghfvs-pr", "5").Forget(); Assert.Equal(7, gitClient.ReceivedCalls().Count()); }