feat: text helpers for report rendering - #2
Open
Bhavikupadhyay wants to merge 2 commits into
Open
Conversation
|
coverage-agent found 2 gap(s), accepted 2 test(s) — scope:
2 accepted test files
--- /dev/null
+++ b/tests/generated/test_coverageagent_truncate_middle.py
@@ -0,0 +1,33 @@
+import pytest
+from coverage_agent.textutil import truncate_middle
+
+def test_truncate_middle_short_text():
+ text = 'abc'
+ max_len = 5
+ assert truncate_middle(text, max_len) == text
+
+def test_truncate_middle_long_text():
+ text = 'abcdefghijklmnopqrstuvwxyz'
+ max_len = 10
+ result = truncate_middle(text, max_len)
+ assert len(result) <= max_len
+ assert result.startswith(text[:3]) and result.endswith(text[-3:])
+
+def test_truncate_middle_max_len_3():
+ text = 'abcdefghijklmnopqrstuvwxyz'
+ max_len = 3
+ result = truncate_middle(text, max_len)
+ assert len(result) <= max_len
+ assert result == text[:max_len]
+
+def test_truncate_middle_zero_max_len():
+ text = 'abcdefghijklmnopqrstuvwxyz'
+ max_len = 0
+ result = truncate_middle(text, max_len)
+ assert result == ""
+
+def test_truncate_middle_negative_max_len():
+ text = 'abcdefghijklmnopqrstuvwxyz'
+ max_len = -1
+ result = truncate_middle(text, max_len)
+ assert result == ""```
**`tests/generated/test_coverageagent_pluralize.py`**
```diff
--- /dev/null
+++ b/tests/generated/test_coverageagent_pluralize.py
@@ -0,0 +1,11 @@
+import pytest
+from coverage_agent.textutil import pluralize
+
+def test_pluralize_default_plural():
+ assert pluralize(2, 'cat') == '2 cats'
+ assert pluralize(3, 'dog') == '3 dogs'
+
+def test_pluralize_custom_plural():
+ assert pluralize(2, 'cat', 'cats') == '2 cats'
+ assert pluralize(3, 'dog', 'dogs') == '3 dogs'
+ assert pluralize(1, 'cat') == '1 cat'```
</details> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
truncate_middleandpluralizefor the PR-comment renderer. No tests included — that's the point: this PR is the live demonstration of coverage-agent generating them.