Skip to content

Commit

Permalink
Add test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
chickenchickenlove committed Feb 3, 2025
1 parent 242cfe5 commit 0c6b138
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/integration/test_content_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0c6b138

Please sign in to comment.