Skip to content

Commit ab07375

Browse files
fix: match Go edge section behavior, update test
1 parent 7ac695a commit ab07375

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/gcf/encode.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ def encode(p: Payload) -> str:
5656
if e.status and e.status != "unchanged":
5757
line += f" {e.status}"
5858
edge_lines.append(line)
59-
if edge_lines:
60-
parts.append("## edges")
61-
parts.extend(edge_lines)
59+
parts.append("## edges")
60+
parts.extend(edge_lines)
6261

6362
return "\n".join(parts) + "\n"
6463

tests/test_encode.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def test_encode_edge_unchanged_status_omitted():
163163

164164

165165
def test_encode_skips_edges_with_missing_symbols():
166-
"""Edges referencing symbols not in the payload are skipped."""
166+
"""Edges referencing unknown symbols are skipped, but section header emitted."""
167167
p = Payload(
168168
tool="test",
169169
symbols=[
@@ -174,7 +174,10 @@ def test_encode_skips_edges_with_missing_symbols():
174174
],
175175
)
176176
output = encode(p)
177-
assert "## edges" not in output
177+
# Section header is emitted (matches Go), but no edge lines beneath it
178+
assert "## edges" in output
179+
lines_after_edges = output.split("## edges\n")[1]
180+
assert lines_after_edges.strip() == ""
178181

179182

180183
def test_encode_empty_payload():

0 commit comments

Comments
 (0)