Unit Tests
- Fixed exected error for on-add-misbehave5. This highlights a potential error in the test suite with the one failing test.
This commit is contained in:
@@ -452,33 +452,27 @@ void Hooks::assertValidJSON (const std::vector <std::string>& input) const
|
|||||||
|
|
||||||
if (((json::object*)root)->_data.find ("description") == ((json::object*)root)->_data.end ())
|
if (((json::object*)root)->_data.find ("description") == ((json::object*)root)->_data.end ())
|
||||||
{
|
{
|
||||||
context.error ("Hook Error: JSON Object missing 'description' attribute: '{\"description\":\"...\",...}'.");
|
context.error ("Hook Error: JSON Object missing 'description' attribute.");
|
||||||
throw 0;
|
throw 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((json::object*)root)->_data.find ("uuid") == ((json::object*)root)->_data.end ())
|
if (((json::object*)root)->_data.find ("uuid") == ((json::object*)root)->_data.end ())
|
||||||
{
|
{
|
||||||
context.error ("Hook Error: JSON Object missing 'uuid' attribute: '{\"uuid\":\"...\",...}'.");
|
context.error ("Hook Error: JSON Object missing 'uuid' attribute.");
|
||||||
throw 0;
|
throw 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (const std::string& e)
|
catch (const std::string& e)
|
||||||
{
|
{
|
||||||
if (_debug >= 1)
|
context.error ("Hook Error: JSON syntax error in: " + *i);
|
||||||
context.error ("Hook Error: JSON syntax error in: " + *i);
|
context.error ("Hook Error: JSON " + e);
|
||||||
|
|
||||||
if (_debug >= 2)
|
|
||||||
context.error ("Hook Error: JSON " + e);
|
|
||||||
|
|
||||||
throw 0;
|
throw 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
if (_debug >= 1)
|
context.error ("Hook Error: JSON failed to parse: " + *i);
|
||||||
context.error ("Hook Error: JSON fails to parse: " + *i);
|
|
||||||
|
|
||||||
throw 0;
|
throw 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ class TestHooksOnAdd(TestCase):
|
|||||||
self.t.hooks.add_default(hookname, log=True)
|
self.t.hooks.add_default(hookname, log=True)
|
||||||
|
|
||||||
code, out, err = self.t.runError(("add", "foo"))
|
code, out, err = self.t.runError(("add", "foo"))
|
||||||
self.assertIn("ERROR SYNTACTICALLY WRONG JSON", err)
|
self.assertIn("Hook Error: JSON syntax error in: {\"}", err)
|
||||||
self.t.hooks[hookname].assertTriggered()
|
self.t.hooks[hookname].assertTriggered()
|
||||||
self.t.hooks[hookname].assertTriggeredCount(1)
|
self.t.hooks[hookname].assertTriggeredCount(1)
|
||||||
self.t.hooks[hookname].assertExitcode(0)
|
self.t.hooks[hookname].assertExitcode(0)
|
||||||
@@ -134,7 +134,7 @@ class TestHooksOnAdd(TestCase):
|
|||||||
self.t.hooks.add_default(hookname, log=True)
|
self.t.hooks.add_default(hookname, log=True)
|
||||||
|
|
||||||
code, out, err = self.t.runError(("add", "foo"))
|
code, out, err = self.t.runError(("add", "foo"))
|
||||||
self.assertIn("Hook Error: JSON Object missing 'uuid' attribute:", err)
|
self.assertIn("Hook Error: JSON Object missing 'uuid' attribute.", err)
|
||||||
self.t.hooks[hookname].assertTriggered()
|
self.t.hooks[hookname].assertTriggered()
|
||||||
self.t.hooks[hookname].assertTriggeredCount(1)
|
self.t.hooks[hookname].assertTriggeredCount(1)
|
||||||
self.t.hooks[hookname].assertExitcode(0)
|
self.t.hooks[hookname].assertExitcode(0)
|
||||||
|
|||||||
Reference in New Issue
Block a user