Skip to content

Commit

Permalink
Added test for bug #3
Browse files Browse the repository at this point in the history
  • Loading branch information
msiemens committed Jun 5, 2013
1 parent 077ff76 commit 4bae5e9
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions tests/test_returning_to_branch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# System imports
import os
from os.path import join

# 3rd party libs
from nose.tools import *
from git import *

# PyGitup imports
from PyGitUp.git_wrapper import GitError
from tests import basepath, write_file, init_master, update_file, testfile_name

test_name = 'returning-to-branch'
new_branch_name = test_name + '.2'

repo_path = join(basepath, test_name + os.sep)

def _read_file(path):
with open(path) as f:
return f.read()


def setup():
master_path, master = init_master(test_name)

# Prepare master repo
master.git.checkout(b=test_name)

# Clone to test repo
path = join(basepath, test_name)

master.clone(path, b=test_name)
repo = Repo(path, odbt=GitCmdObjectDB)

assert repo.working_dir == path

# Create a new branch in repo
repo.git.checkout(b=new_branch_name)

# Modify file in master
master_file = update_file(master, test_name)


def test_ahead_of_upstream():
""" Run 'git up': return to branch """
os.chdir(repo_path)

from PyGitUp.gitup import GitUp
gitup = GitUp()
gitup.run(testing=True)

assert_equal(len(gitup.states), 1)
assert_equal(gitup.states[0], 'fast-forwarding')
assert_equal(gitup.repo.head.ref.name, new_branch_name)

0 comments on commit 4bae5e9

Please sign in to comment.