cmd_release test.
authorCarl Hetherington <cth@carlh.net>
Tue, 8 Dec 2015 23:35:58 +0000 (23:35 +0000)
committerCarl Hetherington <cth@carlh.net>
Tue, 8 Dec 2015 23:35:58 +0000 (23:35 +0000)
cdist/tests/test_cmd_release.py [new file with mode: 0644]

diff --git a/cdist/tests/test_cmd_release.py b/cdist/tests/test_cmd_release.py
new file mode 100644 (file)
index 0000000..400e8af
--- /dev/null
@@ -0,0 +1,57 @@
+#
+#    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+
+#    You should have received a copy of the GNU General Public License
+#    along with this program; if not, write to the Free Software
+#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+import os
+import shutil
+from unittest import TestCase
+
+import cdist.cmd_release
+import cdist.globals
+from cdist.util import command
+import prepare
+
+class TestCmdRelease(TestCase):
+    def test(self):
+
+        prepare.project()
+        os.chdir('test/project.git')
+        with open('wscript', 'w') as f:
+            print>>f,"VERSION = '0.0.1'"
+        command('git add wscript')
+        command('git commit -a -m "foo"')
+        # Allow pushing to a non-bare repo for this test
+        command('git config receive.denyCurrentBranch ignore')
+        os.chdir('../..')
+
+        class Args:
+            target = 'test'
+            debug = False
+            work = 'test'
+            project = 'project'
+            checkout = None
+            keep = False
+            output = os.path.abspath('test')
+            minor = True
+        cdist.globals.config.set('git_prefix', 'test')
+        cdist.cmd_release.CmdRelease().run(Args())
+
+        os.chdir('test/project.git')
+        # We're messing about pushing stuff to a non-bare repo, so we need
+        # to update it here
+        command('git reset --hard')
+        with open('wscript', 'r') as f:
+            self.assertEquals(f.readline().strip(), "VERSION = '0.1.0devel'")