public async Task DoesNotPushEmptyRepository() { var repository = Substitute.For<IRepository>(); var gitClient = new GitClient(); await gitClient.Push(repository, "master", "origin"); repository.Network.DidNotReceive() .Push(Args.Remote, Args.String, Args.String, Arg.Any<PushOptions>(), Arg.Any<Signature>(), Args.String); }
public async Task DoesNotPushEmptyRepository() { var repository = Substitute.For<IRepository>(); var gitClient = new GitClient(Substitute.For<IGitHubCredentialProvider>()); await gitClient.Push(repository, "master", "origin"); repository.Network.DidNotReceive() .Push(Args.Remote, Args.String, Args.String); }
public async Task SetsTheConfigToTheRemoteBranch() { var config = Substitute.For<Configuration>(); var repository = Substitute.For<IRepository>(); repository.Config.Returns(config); var gitClient = new GitClient(); await gitClient.SetRemote(repository, "origin", new Uri("https://github.com/foo/bar")); config.Received().Set<string>("remote.origin.url", "https://github.com/foo/bar"); config.Received().Set<string>("remote.origin.fetch", "+refs/heads/*:refs/remotes/origin/*"); }
public async Task PushesToDefaultOrigin() { var origin = Substitute.For<Remote>(); var head = Substitute.For<Branch>(); head.Commits.Returns(new FakeCommitLog { Substitute.For<Commit>() }); var repository = Substitute.For<IRepository>(); repository.Head.Returns(head); repository.Network.Remotes["origin"].Returns(origin); var gitClient = new GitClient(); await gitClient.Push(repository, "master", "origin"); repository.Network.Received().Push(origin,"HEAD", @"refs/heads/master", null, null, null); }
public async Task SetsTheRemoteTrackingBranch() { var config = Substitute.For<Configuration>(); var origin = Substitute.For<Remote>(); var branches = Substitute.For<BranchCollection>(); var repository = Substitute.For<IRepository>(); repository.Config.Returns(config); repository.Branches.Returns(branches); repository.Network.Remotes["origin"].Returns(origin); var localBranch = Substitute.For<Branch>(); var remoteBranch = Substitute.For<Branch>(); ; branches["refs/heads/master"].Returns(localBranch); branches["refs/remotes/origin/master"].Returns(remoteBranch); var gitClient = new GitClient(); await gitClient.SetTrackingBranch(repository, "master", "origin"); branches.Received().Update(localBranch, Arg.Any<Action<BranchUpdater>>()); }