Permalink
Browse files

Add a test for init with the empty part specified

  • Loading branch information...
1 parent 58d08aa commit 9118f2bb67c10c868109cdc5d3ac5052bbe28121 @plars committed Nov 5, 2015
Showing with 28 additions and 0 deletions.
  1. +28 −0 snapcraft/tests/test_cmds.py
@@ -252,5 +252,33 @@ def test_init_without_parts_must_write_snapcraft_yaml(self, mock_stdout):
summary: # 79 char long summary
description: # A longer description for the snap
icon: # A path to an icon for the package
+'''
+ self.assertEqual(mock_stdout.getvalue(), expected_out)
+
+ @mock.patch('sys.stdout', new_callable=io.StringIO)
+ def test_init_with_parts(self, mock_stdout):
+ fake_logger = fixtures.FakeLogger(level=logging.INFO)
+ self.useFixture(fake_logger)
+
+ snap_with_parts = type('obj', (object, ), {'part': ['empty']})
+
+ with self.assertRaises(SystemExit) as raised:
+ cmds.init(snap_with_parts)
+
+ self.assertEqual(raised.exception.code, 0, 'Wrong exit code returned.')
+ self.assertEqual(
+ 'Wrote the following as snapcraft.yaml.\n',
+ fake_logger.output)
+
+ expected_out = '''
+name: # the name of the snap
+version: # the version of the snap
+# The vendor for the snap (replace 'Vendor <email@example.com>')
+vendor: Vendor <email@example.com>
+summary: # 79 char long summary
+description: # A longer description for the snap
+icon: # A path to an icon for the package
+parts:
+ empty:
'''
self.assertEqual(mock_stdout.getvalue(), expected_out)

0 comments on commit 9118f2b

Please sign in to comment.