Skip to content

Commit

Permalink
More tests for run_build class
Browse files Browse the repository at this point in the history
Signed-off-by: Zelin Hao <[email protected]>
  • Loading branch information
zelinh committed Dec 14, 2023
1 parent 87fddd6 commit cbad22f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/run_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def main() -> int:
list_of_updated_plugins = buildIncremental.commits_diff(manifest)
components = buildIncremental.rebuild_plugins(list_of_updated_plugins, manifest)
logging.info(f"Plugins for incremental build: {components}")
# buildIncremental.build_incremental(args, manifest, ["common-utils"])
buildIncremental.build_incremental(args, manifest, components)
return 0

Expand Down
9 changes: 9 additions & 0 deletions tests/test_run_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,12 @@ def test_failed_plugins_default(self, mock_logging_error: Mock, mock_temp: Mock,
with pytest.raises(Exception, match="Error during build"):
main()
mock_logging_error.assert_called_with(f"Error building common-utils, retry with: run_build.py {self.NON_OPENSEARCH_MANIFEST} --component common-utils")

@patch("argparse._sys.argv", ["run_build.py", OPENSEARCH_MANIFEST, "--incremental"])
@patch("run_build.BuildIncremental")
def test_main_incremental(self, mock_build_incremental: Mock, *mocks: Any) -> None:
main()
self.assertEqual(mock_build_incremental.call_count, 1)
mock_build_incremental.return_value.commits_diff.assert_called()
mock_build_incremental.return_value.rebuild_plugins.assert_called()
mock_build_incremental.return_value.build_incremental.assert_called()
1 change: 0 additions & 1 deletion tests/tests_build_workflow/test_build_incremental.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ def test_rebuild_plugins_with_dashboards(self) -> None:
self.assertTrue("OpenSearch-Dashboards" in rebuild_list)
self.assertTrue("observabilityDashboards" in rebuild_list)

# @patch("argparse._sys.argv", ["run_build.py", INPUT_MANIFEST, "-p", "linux"])
@patch("os.path.join")
@patch("build_workflow.build_incremental.Builders.builder_from", return_value=MagicMock())
@patch("build_workflow.build_incremental.BuildRecorder", return_value=MagicMock())
Expand Down

0 comments on commit cbad22f

Please sign in to comment.