Skip to content

Commit 389c1e3

Browse files
authored
Extend list_issues tests to cover Date/Number/Text field value variants
1 parent a86412f commit 389c1e3

1 file changed

Lines changed: 29 additions & 5 deletions

File tree

pkg/github/issues_test.go

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,23 @@ func Test_ListIssues(t *testing.T) {
14481448
"totalCount": 3,
14491449
},
14501450
"issueFieldValues": map[string]any{
1451-
"nodes": []map[string]any{},
1451+
"nodes": []map[string]any{
1452+
{
1453+
"__typename": "IssueFieldDateValue",
1454+
"field": map[string]any{"name": "due"},
1455+
"value": "2026-06-01",
1456+
},
1457+
{
1458+
"__typename": "IssueFieldNumberValue",
1459+
"field": map[string]any{"name": "estimate"},
1460+
"valueNumber": 2.5,
1461+
},
1462+
{
1463+
"__typename": "IssueFieldTextValue",
1464+
"field": map[string]any{"name": "notes"},
1465+
"value": "needs triage",
1466+
},
1467+
},
14521468
},
14531469
},
14541470
}
@@ -1721,11 +1737,19 @@ func Test_ListIssues(t *testing.T) {
17211737
assert.NotEmpty(t, label, "Label should be a non-empty string")
17221738
}
17231739

1724-
// Field values should be flattened to {field, value} pairs. Issue #123 in the mock
1725-
// data has a SingleSelectValue for "priority"; all others have an empty list.
1726-
if issue.Number == 123 {
1740+
// Field values should be flattened to {field, value} pairs. Issue #123 has a
1741+
// SingleSelectValue; issue #456 exercises the Date/Number/Text branches
1742+
// (including float formatting); #789 has no field values.
1743+
switch issue.Number {
1744+
case 123:
17271745
assert.Equal(t, []MinimalIssueFieldValue{{Field: "priority", Value: "P1"}}, issue.FieldValues)
1728-
} else {
1746+
case 456:
1747+
assert.Equal(t, []MinimalIssueFieldValue{
1748+
{Field: "due", Value: "2026-06-01"},
1749+
{Field: "estimate", Value: "2.5"},
1750+
{Field: "notes", Value: "needs triage"},
1751+
}, issue.FieldValues)
1752+
default:
17291753
assert.Empty(t, issue.FieldValues)
17301754
}
17311755
}

0 commit comments

Comments
 (0)