aboutsummaryrefslogtreecommitdiff
path: root/infra/cifuzz/filestore_utils_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'infra/cifuzz/filestore_utils_test.py')
-rw-r--r--infra/cifuzz/filestore_utils_test.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/infra/cifuzz/filestore_utils_test.py b/infra/cifuzz/filestore_utils_test.py
new file mode 100644
index 000000000..db5fc5bc1
--- /dev/null
+++ b/infra/cifuzz/filestore_utils_test.py
@@ -0,0 +1,50 @@
+# Copyright 2021 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+"""Tests for filestore_utils."""
+import unittest
+from unittest import mock
+
+import parameterized
+
+import config_utils
+import filestore
+from filestore import github_actions
+import filestore_utils
+import test_helpers
+
+
+class GetFilestoreTest(unittest.TestCase):
+ """Tests for get_filestore."""
+
+ @parameterized.parameterized.expand([
+ ({
+ 'is_github': True,
+ }, github_actions.GithubActionsFilestore),
+ ])
+ def test_get_filestore(self, config_kwargs, filestore_cls):
+ """Tests that get_filestore returns the right filestore given a certain
+ platform."""
+ run_config = test_helpers.create_run_config(**config_kwargs)
+ filestore_impl = filestore_utils.get_filestore(run_config)
+ self.assertIsInstance(filestore_impl, filestore_cls)
+
+ @mock.patch('config_utils.BaseConfig.platform', return_value='other')
+ @mock.patch('config_utils._get_ci_environment',
+ return_value=config_utils.GenericCiEnvironment())
+ def test_get_filestore_unsupported_platform(self, _, __):
+ """Tests that get_filestore exceptions given a platform it doesn't
+ support."""
+ run_config = test_helpers.create_run_config()
+ with self.assertRaises(filestore.FilestoreError):
+ filestore_utils.get_filestore(run_config)