Skip to content

feat: text helpers for report rendering - #2

Open
Bhavikupadhyay wants to merge 2 commits into
mainfrom
demo/textutil
Open

feat: text helpers for report rendering#2
Bhavikupadhyay wants to merge 2 commits into
mainfrom
demo/textutil

Conversation

@Bhavikupadhyay

Copy link
Copy Markdown
Owner

Adds truncate_middle and pluralize for the PR-comment renderer. No tests included — that's the point: this PR is the live demonstration of coverage-agent generating them.

@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown

coverage-agent found 2 gap(s), accepted 2 test(s) — scope: diff · model: groq/llama-3.3-70b-versatile

Gap Kind Result Targets hit
coverage_agent/textutil.py:5->20 function accepted 10/15
coverage_agent/textutil.py:23->28 function accepted 4/5
2 accepted test files

tests/generated/test_coverageagent_truncate_middle.py

--- /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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant