From 0c6b138f9f0128bba992040484dbe0cd437bf531 Mon Sep 17 00:00:00 2001 From: chickenchickenlove Date: Mon, 3 Feb 2025 22:18:20 +0900 Subject: [PATCH] Add test cases. --- tests/integration/test_content_service.py | 34 +++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/integration/test_content_service.py b/tests/integration/test_content_service.py index ec3216f..102194b 100644 --- a/tests/integration/test_content_service.py +++ b/tests/integration/test_content_service.py @@ -241,6 +241,40 @@ def test_merge_files(self, run_around_test): assert ret.entry_type == EntryType.JSON assert ret.content == {"foo3": "bar3"} + def test_when_cd_has_a_file_and_get_files_is_called_it_should_be_failed(self, run_around_test): + files = dogma.list_files(project_name, repo_name) + assert len(files) == 0 + + # GIVEN + commit = Commit("Upsert dummy1-test.json") + upsert_json = Change("/test/dummy1-test.json", ChangeType.UPSERT_JSON, {"foo": "bar"}) + dogma.push(project_name, repo_name, commit, [upsert_json]) + + # WHEN + with pytest.raises(AttributeError): + dogma.get_files(project_name, repo_name, '/test/dummy1-test.json') + + def test_when_cd_has_two_files_and_get_files_is_called_it_should_be_success(self, run_around_test): + files = dogma.list_files(project_name, repo_name) + assert len(files) == 0 + + # GIVEN + expected_file_count = 2 + + commit = Commit("Upsert dummy1-test.json") + upsert_json = Change("/dummy1-test.json", ChangeType.UPSERT_JSON, {"foo": "bar"}) + dogma.push(project_name, repo_name, commit, [upsert_json]) + + commit = Commit("Upsert dummy2-test.json") + upsert_json = Change("/dummy2-test.json", ChangeType.UPSERT_JSON, {"foo": "bar"}) + dogma.push(project_name, repo_name, commit, [upsert_json]) + + # WHEN + result = dogma.get_files(project_name, repo_name, '*.json') + + # THEN + assert len(result) == expected_file_count + @staticmethod def push_later(): time.sleep(1)