summaryrefslogtreecommitdiff
path: root/buildbot
diff options
context:
space:
mode:
authorMike Frysinger <vapier@chromium.org>2014-05-19 11:56:40 -0400
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-05-19 23:06:43 +0000
commit5123874504fa13e2adec9a7d080a8b2714108d29 (patch)
tree01877a5c4b6722d667aeffa399c26e00a0cf06fb /buildbot
parent4bd1fa73d418f2a06c99cd4b70a87bace64f7428 (diff)
downloadchromite-5123874504fa13e2adec9a7d080a8b2714108d29.tar.gz
trybot_patch_pool: add some unittests
Write some tests as this module doesn't have any (!). BUG=chromium:374792 TEST=`buildbot/trybot_patch_pool.py` fails w/out CL:200381 TEST=`buildbot/trybot_patch_pool.py` passes w/CL:200381 CQ-DEPEND=CL:200076 Change-Id: I611becaf5ed16e70e3c7701fb2ff46d9ebb68ae5 Reviewed-on: https://chromium-review.googlesource.com/200077 Reviewed-by: Mike Frysinger <vapier@chromium.org> Commit-Queue: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org>
Diffstat (limited to 'buildbot')
-rwxr-xr-xbuildbot/trybot_patch_pool_unittests.py62
1 files changed, 62 insertions, 0 deletions
diff --git a/buildbot/trybot_patch_pool_unittests.py b/buildbot/trybot_patch_pool_unittests.py
new file mode 100755
index 000000000..2002339db
--- /dev/null
+++ b/buildbot/trybot_patch_pool_unittests.py
@@ -0,0 +1,62 @@
+#!/usr/bin/python
+# Copyright 2014 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Unittests for trybot_patch_pool."""
+
+from __future__ import print_function
+
+import sys
+
+import constants
+sys.path.insert(0, constants.SOURCE_ROOT)
+from chromite.buildbot import trybot_patch_pool
+from chromite.lib import cros_test_lib
+from chromite.lib import patch as cros_patch
+from chromite.lib import patch_unittest
+
+
+class FilterTests(patch_unittest.GitRepoPatchTestCase):
+ """Tests for all the various filters."""
+
+ patch_kls = cros_patch.LocalPatch
+
+ def testChromiteFilter(self):
+ """Make sure the chromite filter works"""
+ _, _, patch = self._CommonGitSetup()
+ patch.project = constants.CHROMITE_PROJECT
+ self.assertTrue(trybot_patch_pool.ChromiteFilter(patch))
+ patch.project = 'foooo'
+ self.assertFalse(trybot_patch_pool.ChromiteFilter(patch))
+
+ def testManifestFilters(self):
+ """Make sure the manifest filters work"""
+ _, _, patch = self._CommonGitSetup()
+
+ patch.project = constants.CHROMITE_PROJECT
+ self.assertFalse(trybot_patch_pool.ExtManifestFilter(patch))
+ self.assertFalse(trybot_patch_pool.IntManifestFilter(patch))
+ self.assertFalse(trybot_patch_pool.ManifestFilter(patch))
+
+ patch.project = constants.MANIFEST_PROJECT
+ self.assertTrue(trybot_patch_pool.ExtManifestFilter(patch))
+ self.assertFalse(trybot_patch_pool.IntManifestFilter(patch))
+ self.assertTrue(trybot_patch_pool.ManifestFilter(patch))
+
+ patch.project = constants.MANIFEST_INT_PROJECT
+ self.assertFalse(trybot_patch_pool.ExtManifestFilter(patch))
+ self.assertTrue(trybot_patch_pool.IntManifestFilter(patch))
+ self.assertTrue(trybot_patch_pool.ManifestFilter(patch))
+
+ def testBranchFilter(self):
+ """Make sure the branch filter works"""
+ _, _, patch = self._CommonGitSetup()
+
+ self.assertFalse(trybot_patch_pool.BranchFilter('/,/asdf', patch))
+ self.assertTrue(trybot_patch_pool.BranchFilter(
+ patch.tracking_branch, patch))
+
+
+if __name__ == '__main__':
+ cros_test_lib.main()