diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2014-03-27 11:57:21 +0000 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2014-03-27 11:57:21 +0000 |
commit | 3e5fd7059ced17a61df21e1c49f465eaf1748d27 (patch) | |
tree | 95fc6faa5d0b73a7c249e73fbd2c5b74695a01bf | |
parent | 1e1e225c9e6a2b6229fe7f146c43b0644073fad6 (diff) | |
download | lorry-controller-3e5fd7059ced17a61df21e1c49f465eaf1748d27.tar.gz |
Add validation tests for .lorry files
-rw-r--r-- | yarns.webapp/060-validation.yarn | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/yarns.webapp/060-validation.yarn b/yarns.webapp/060-validation.yarn index a66e889..588d875 100644 --- a/yarns.webapp/060-validation.yarn +++ b/yarns.webapp/060-validation.yarn @@ -118,6 +118,50 @@ them to Lorry one by one. In other words: * The `.lorry` file must be valid JSON. * It must be a dict. * Each key must map to another dict. -* Each inner dict must have a key "type", which maps to a string. +* Each inner dict must have a key `type`, which maps to a string. -Everything else is left for Lorry itself. +Everything else is left for Lorry itself. Lorry Controller only needs +to handle Lorry not working, and it already does that. + +Firstly, some setup. + + SCENARIO validate .lorry files + GIVEN a new git repository in CONFGIT + AND an empty lorry-controller.conf in CONFGIT + AND lorry-controller.conf in CONFGIT adds lorries *.lorry using prefix upstream + AND WEBAPP uses CONFGIT as its configuration directory + AND a running WEBAPP + +Make sure WEBAPP handles there not being any `.lorry` files. + + WHEN admin makes request POST /1.0/read-configuration with dummy=value + THEN response matches "has been updated" + AND STATEDB is empty + +Add a `.lorry` file that contains broken JSON. + + GIVEN Lorry file notjson.lorry with THIS IS NOT JSON + THEN response matches "has been updated" + AND STATEDB is empty + +Add a `.lorry` file that is valid JSON, but is not a dict. + + GIVEN Lorry file notadict.lorry with [1,2,3] + THEN response matches "has been updated" + AND STATEDB is empty + +Add a `.lorry` that is a dict, but doesn't map keys to dicts. + + GIVEN Lorry file notadictofdicts.lorry with { "foo": 1 } + THEN response matches "has been updated" + AND STATEDB is empty + +Add a `.lorry` whose inner dict does not have a `type` field. + + GIVEN Lorry file notadictofdicts.lorry with { "foo": { "bar": "yo" }} + THEN response matches "has been updated" + AND STATEDB is empty + +Clean up at the end. + + FINALLY WEBAPP terminates |