Add gpconfig unit test for change value and master flags
@@ -26,7 +26,7 @@ class GpConfig(GpTestCase):
# self.subject = gpconfig
gpconfig_file = os.path.abspath(os.path.dirname(__file__) + "/../../../gpconfig")
self.subject = imp.load_source('gpconfig', gpconfig_file)
- self.subject.logger = Mock(spec=['log', 'warn', 'info', 'debug', 'error', 'warning'])
+ self.subject.logger = Mock(spec=['log', 'warn', 'info', 'debug', 'error', 'warning', 'fatal'])
self.conn = Mock()
self.rows = []
@@ -171,6 +171,24 @@ class GpConfig(GpTestCase):
self.assertIn("bar", mock_stdout.getvalue())
self.assertIn("baz", mock_stdout.getvalue())
+ def test_option_change_value_masteronly_succeed(self):
+ entry = 'my_property_name'
+ sys.argv = ["gpconfig", "-c", entry, "-v", "100", "-m", "20"]
+ # 'SELECT name, setting, unit, short_desc, context, vartype, min_val, max_val FROM pg_settings'
+ self.rows.extend([['my_property_name', 'setting', 'unit', 'short_desc',
+ 'context', 'vartype', 'min_val', 'max_val']])
+ self.subject.do_main()
+
+
+ def test_option_change_value_masteronly_fail_not_valid_guc(self):
+ sys.argv = ["gpconfig", "-c", "my_property_name", "-v", "100", "-m", "20"]
+
+ with self.assertRaises(SystemExit) as cm:
+ self.subject.do_main()
+
+ self.assertEqual(self.subject.logger.fatal.call_count, 1)
+ self.assertEqual(cm.exception.code, 1)
+
if __name__ == '__main__':
run_tests()
