Commit de170a56 authored by Ayush Tiwari's avatar Ayush Tiwari

Add check for update method call

parent 468f3883
......@@ -132,6 +132,11 @@ class GitCloneNonInformativeTests(unittest.TestCase):
def touch(self, *parts):
os.close(os.open(os.path.join(*parts), os.O_CREAT, 0o666))
def echo(self, path, line):
myFile = open(path, 'w')
myFile.write(line)
myFile.close()
def makeGitCloneRecipe(self, options):
from slapos.recipe.gitclone import Recipe
bo = {
......@@ -177,7 +182,8 @@ class GitCloneNonInformativeTests(unittest.TestCase):
self.assertFalse(os.path.exists(bad_file_path), "pyc file not removed")
@with_buildout
def test_clone_and_udpate_submodule(self, buildout, write, sample_buildout, **kw):
def test_clone_and_update_submodule(self, buildout, write, sample_buildout,
**kw):
"""
STEP I:
Repositories status: Main repo(M1) and Submodule repo (S1)
......@@ -219,6 +225,29 @@ repository = %s
head_commit_submodule_after_clone = self.getRepositoryHeadCommit(
submodule_repo_path)
# Add a marker file in parent as well as submodule repo
parent_local_change_path = os.path.join(main_repo_path,
'local_change_main')
submodule_local_change_path = os.path.join(submodule_repo_path,
'local_change_submodule')
self.echo(parent_local_change_path, 'foo')
self.echo(submodule_local_change_path, 'bar')
# Check if the file are created at the expected position and check contents
self.assertTrue(os.path.exists(parent_local_change_path))
self.assertTrue(os.path.exists(submodule_local_change_path))
self.assertEqual(check_output(['cat', parent_local_change_path]), 'foo')
self.assertEqual(check_output(['cat', submodule_local_change_path]), 'bar')
# Update buildout
check_call([buildout])
# The local changes should be still there
self.assertTrue(os.path.exists(parent_local_change_path))
self.assertTrue(os.path.exists(submodule_local_change_path))
self.assertEqual(check_output(['cat', parent_local_change_path]), 'foo')
self.assertEqual(check_output(['cat', submodule_local_change_path]), 'bar')
# Update submodule repository and main repo separately
self.touch(self.project_dir, 'file2.py')
self.gitAdd(self.project_dir)
......@@ -246,8 +275,13 @@ revision = %s
# Check if the submodule is not empty
self.assertTrue(os.listdir(submodule_repo_path))
# Since calling buildout should've reinstalled, we expect the local changes
# to be gone
self.assertFalse(os.path.exists(parent_local_change_path))
self.assertFalse(os.path.exists(submodule_local_change_path))
# Get the head commit of the submodule repo
head_commit_submodule_after_first_update = self.getRepositoryHeadCommit(
head_commit_submodule_after_first_revision = self.getRepositoryHeadCommit(
submodule_repo_path)
# Update main repo with changes of submodule
......@@ -276,18 +310,18 @@ revision = %s
# Check if the submodule is not empty
self.assertTrue(os.listdir(submodule_repo_path))
# Get the head commit of the submodule repo
head_commit_submodule_after_second_update = self.getRepositoryHeadCommit(
head_commit_submodule_after_second_revision = self.getRepositoryHeadCommit(
submodule_repo_path)
# Check the HEAD of the submodule
submodule_head_commit = self.getRepositoryHeadCommit(self.submodule_dir)
self.assertEqual(head_commit_submodule_after_clone,
head_commit_submodule_after_first_update)
head_commit_submodule_after_first_revision)
self.assertNotEqual(head_commit_submodule_after_first_update,
head_commit_submodule_after_second_update)
self.assertNotEqual(head_commit_submodule_after_first_revision,
head_commit_submodule_after_second_revision)
self.assertEqual(head_commit_submodule_after_second_update,
self.assertEqual(head_commit_submodule_after_second_revision,
submodule_head_commit)
def test_ignore_ssl_certificate(self, ignore_ssl_certificate=True):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment