def test_ref_does_not_exist(self, mock_check_output: MagicMock) -> None:
     component = InputComponentFromSource({"name": "common-utils", "repository": "url", "ref": "ref"})
     with self.assertRaises(CiCheckListSourceRef.MissingRefError) as ctx:
         list = CiCheckListSourceRef(component, MagicMock())
         list.check()
     self.assertEqual("Missing url@ref.", str(ctx.exception))
     mock_check_output.assert_called_with("git ls-remote url ref", shell=True)
Exemple #2
0
 def test_from_component_source(self):
     check_list = CiCheckLists.from_component(
         InputComponentFromSource({
             "name": "common-utils",
             "repository": "url",
             "ref": "ref"
         }), None)
     self.assertIs(type(check_list), CiCheckListSource)
Exemple #3
0
 def test_checkout(self, mock_git_repo):
     component = InputComponentFromSource({
         "name": "common-utils",
         "repository": "url",
         "ref": "ref"
     })
     list = CiCheckListSource(component, MagicMock())
     list.checkout("path")
     mock_git_repo.assert_called()
Exemple #4
0
 def test_invalid_check(self, *mocks):
     component = InputComponentFromSource({
         "name": "common-utils",
         "repository": "url",
         "ref": "ref",
         "checks": ["invalid:check"]
     })
     list = CiCheckListSource(component, MagicMock())
     list.checkout("path")
     with self.assertRaises(CiCheckListSource.InvalidCheckError) as ctx:
         list.check()
     self.assertTrue(
         str(ctx.exception).startswith("Invalid check: invalid:check"))
 def setUp(self) -> None:
     self.builder = BuilderFromSource(
         InputComponentFromSource({
             "name": "common-utils",
             "repository": "url",
             "ref": "ref"
         }),
         BuildTarget(
             name="OpenSearch",
             version="1.1.0",
             platform="linux",
             architecture="x64",
             snapshot=False,
         ),
     )
Exemple #6
0
 def test_check(self, mock_properties_file, mock_check, *mocks):
     component = InputComponentFromSource({
         "name":
         "common-utils",
         "repository":
         "url",
         "ref":
         "ref",
         "checks": ["gradle:properties:version"]
     })
     list = CiCheckListSource(component, MagicMock())
     list.checkout("path")
     list.check()
     # patching ci_workflow.ci_check_list_source.CiCheckGradlePropertiesVersion#check doesn't work
     # but it creates an instance of PropertiesFile
     mock_properties_file.assert_called()
 def test_ref_exists(self, mock_check_output: MagicMock) -> None:
     component = InputComponentFromSource({"name": "common-utils", "repository": "url", "ref": "ref"})
     list = CiCheckListSourceRef(component, MagicMock())
     list.check()
     mock_check_output.assert_called_with("git ls-remote url ref", shell=True)
Exemple #8
0
    def setUp(self) -> None:
        self.builder = BuilderFromSource(
            InputComponentFromSource({
                "name": "sample_component",
                "repository": "url",
                "ref": "ref"
            }),
            BuildTarget(
                name="OpenSearch",
                version="1.1.0",
                platform="linux",
                architecture="x64",
                snapshot=False,
            ),
        )

        self.builder_distribution = BuilderFromSource(
            InputComponentFromSource({
                "name": "OpenSearch",
                "repository": "url",
                "ref": "ref"
            }),
            BuildTarget(
                name="OpenSearch",
                version="1.3.0",
                platform="linux",
                architecture="x64",
                distribution="tar",
                snapshot=False,
            ),
        )

        self.builder_distribution_support = BuilderFromSource(
            InputComponentFromSource({
                "name": "sample_component",
                "repository": "url",
                "ref": "ref"
            }),
            BuildTarget(
                name="OpenSearch",
                version="1.3.0",
                platform="linux",
                architecture="x64",
                distribution="rpm",
                snapshot=False,
            ),
        )

        self.builder_distribution_support_component_not_found = BuilderFromSource(
            InputComponentFromSource({
                "name": "not_found_component",
                "repository": "url",
                "ref": "ref"
            }),
            BuildTarget(
                name="OpenSearch",
                version="1.3.0",
                platform="linux",
                architecture="x64",
                distribution="rpm",
                snapshot=False,
            ),
        )