From 4e9b7de79f4a0b19c16de14d8ce2e58a23e38e29 Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Fri, 21 Feb 2020 09:18:56 +0100 Subject: [PATCH] Add tests for git.AddRemote and git.PushToRemote We now add some testing around the two new API methods. Signed-off-by: Sascha Grunert --- pkg/git/git_integration_test.go | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/pkg/git/git_integration_test.go b/pkg/git/git_integration_test.go index 1afcd1d293f..c7911e1032b 100644 --- a/pkg/git/git_integration_test.go +++ b/pkg/git/git_integration_test.go @@ -651,3 +651,43 @@ func TestOpenRepoFailure(t *testing.T) { require.NotNil(t, err) require.Nil(t, repo) } + +func TestAddRemoteSuccess(t *testing.T) { + testRepo := newTestRepo(t) + defer testRepo.cleanup(t) + + err := testRepo.sut.AddRemote("remote", "owner", "repo") + require.Nil(t, err) +} + +func TestAddRemoteFailureAlreadyExisting(t *testing.T) { + testRepo := newTestRepo(t) + defer testRepo.cleanup(t) + + err := testRepo.sut.AddRemote(git.DefaultRemote, "owner", "repo") + require.NotNil(t, err) +} + +func TestPushToRemoteSuccessRemoteMaster(t *testing.T) { + testRepo := newTestRepo(t) + defer testRepo.cleanup(t) + + err := testRepo.sut.PushToRemote(git.DefaultRemote, git.Remotify(git.Master)) + require.Nil(t, err) +} + +func TestPushToRemoteSuccessBranchTracked(t *testing.T) { + testRepo := newTestRepo(t) + defer testRepo.cleanup(t) + + err := testRepo.sut.PushToRemote(git.DefaultRemote, testRepo.branchName) + require.Nil(t, err) +} + +func TestPushToRemoteFailureBranchNotExisting(t *testing.T) { + testRepo := newTestRepo(t) + defer testRepo.cleanup(t) + + err := testRepo.sut.PushToRemote(git.DefaultRemote, "some-branch") + require.NotNil(t, err) +}