From 5622c410b67feab3eb548cc15d203b7392a8cff5 Mon Sep 17 00:00:00 2001 From: Francesco Siddi Date: Thu, 11 Dec 2014 20:08:20 +0100 Subject: [PATCH] Added test for commits after new session creation --- tests/test_cli.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/test_cli.py b/tests/test_cli.py index 816d2f0..a8d4a8c 100755 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -804,6 +804,37 @@ class BamCommitTest(BamSessionTestCase): ["M", "d_dir/d_subdir/d_nested/d.data"], ], ret) + def test_create_commit_update(self): + """After creating a new session, we commit its content. Then, we do some + edits and we commit again. + """ + + session_name = "mysession" + file_name = "testfile.txt" + file_data = b"hello world!\n" + + proj_path, session_path = self.init_session(session_name) + + # now do a real commit + file_quick_write(session_path, file_name, file_data) + stdout, stderr = bam_run(["commit", "-m", "test message"], session_path) + self.assertEqual("", stderr) + + # edit the file within the same session + new_file_data = b"goodbye cruel world!\n" + file_quick_write(session_path, file_name, new_file_data) + stdout, stderr = bam_run(["commit", "-m", "session second commit"], session_path) + self.assertEqual("", stderr) + + # remove the path + shutil.rmtree(session_path) + + # checkout the file again and compare its content with the committed change + stdout, stderr = bam_run(["checkout", file_name, "--output", session_path], proj_path) + self.assertEqual("", stderr) + self.assertTrue(os.path.exists(os.path.join(session_path, file_name))) + + class BamCheckoutTest(BamSessionTestCase): """Test for the `bam checkout` command. """