Get some insight on failing tests

This commit is contained in:
Pedro Algarvio 2020-05-05 18:56:30 +01:00 committed by Daniel Wozniak
parent bf6b61a0e5
commit 81f43fb67f
3 changed files with 19 additions and 12 deletions

View file

@ -254,10 +254,11 @@ class CMDModuleTest(ModuleCase):
"""
cmd.which
"""
self.assertEqual(
self.run_function("cmd.which", ["cat"]).rstrip(),
self.run_function("cmd.run", ["which cat"]).rstrip(),
)
cmd_which = self.run_function("cmd.which", ["cat"])
self.assertIsInstance(cmd_which, str)
cmd_run = self.run_function("cmd.run", ["which cat"])
self.assertIsInstance(cmd_run, str)
self.assertEqual(cmd_which.rstrip(), cmd_run.rstrip())
@skip_if_binaries_missing(["which"])
def test_which_bin(self):
@ -352,13 +353,13 @@ class CMDModuleTest(ModuleCase):
cmd.run with quoted command
"""
cmd = """echo 'SELECT * FROM foo WHERE bar="baz"' """
expected_result = 'SELECT * FROM foo WHERE bar="baz"'
runas = RUNTIME_VARS.RUNNING_TESTS_USER
result = self.run_function("cmd.run_stdout", [cmd], runas=runas).strip()
self.assertEqual(result, expected_result)
result = self.run_function(
"cmd.run_all", [cmd], runas=RUNTIME_VARS.RUNNING_TESTS_USER
)
errmsg = "The command returned: {}".format(result)
self.assertEqual(result["retcode"], 0, errmsg)
self.assertEqual(result["stdout"], expected_result, errmsg)
@destructiveTest
@skip_if_not_root

View file

@ -2364,6 +2364,7 @@ class StateModuleTest(ModuleCase, SaltReturnAssertsMixin):
testfile
)
ret = self.run_function("state.test", ["core"])
self.assertIsInstance(ret, dict)
for key, val in ret.items():
self.assertEqual(val["comment"], comment)

View file

@ -1683,8 +1683,13 @@ class ConfigTestCase(TestCase, AdaptedConfigurationTestCaseMixin):
Tests that cloud.{providers,profiles}.d directories are loaded, even if not
directly passed in through path
"""
log.warning("Clound config file path: %s", self.get_config_file_path("cloud"))
config = salt.config.cloud_config(self.get_config_file_path("cloud"))
config_file = self.get_config_file_path("cloud")
log.debug("Cloud config file path: %s", config_file)
self.assertTrue(
os.path.exists(config_file), "{} does not exist".format(config_file)
)
config = salt.config.cloud_config(config_file)
self.assertIn("providers", config)
self.assertIn("ec2-config", config["providers"])
self.assertIn("ec2-test", config["profiles"])