Skip to content

Commit

Permalink
Added check for ints for caches and added a test.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewongbb committed May 31, 2012
1 parent bee6af8 commit 5b22df9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions master/buildbot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,11 @@ def load_caches(self, filename, config_dict, errors):
if not isinstance(caches, dict):
errors.addError("c['caches'] must be a dictionary")
else:
vals = caches.values()
for x in vals:
if (not isinstance(x, int)):
errors.addError("value must be an int")
valPairs = caches.items()
for (x, y) in valPairs:
if (not isinstance(y, int)):
errors.addError(
"value for cache size '%s' must be an integer" % x)
self.caches.update(caches)

if 'buildCacheSize' in config_dict:
Expand Down
3 changes: 2 additions & 1 deletion master/buildbot/test/unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,8 @@ def test_load_caches_entries_test(self):
self.cfg.load_caches(self.filename,
dict(caches=dict(foo="1")),
self.errors)
self.assertConfigError(self.errors, "must be an int")
self.assertConfigError(self.errors,
"value for cache size 'foo' must be an integer")

def test_load_schedulers_defaults(self):
self.cfg.load_schedulers(self.filename, {}, self.errors)
Expand Down

0 comments on commit 5b22df9

Please sign in to comment.