Skip to content

Commit d13ca17

Browse files
authored
Use helper functions from tools
1 parent 94af699 commit d13ca17

File tree

2 files changed

+15
-23
lines changed

2 files changed

+15
-23
lines changed

e2e/e2e_test.go

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,41 +1807,41 @@ func TestFindClosingPullRequestsGraphQLParameters(t *testing.T) {
18071807
owner: "microsoft",
18081808
repo: "vscode",
18091809
issueNumbers: []int{1},
1810-
includeClosedPrs: boolPtr(true),
1810+
includeClosedPrs: github.ToBoolPtr(true),
18111811
description: "Test includeClosedPrs parameter with popular repository",
18121812
},
18131813
{
18141814
name: "includeClosedPrs=false - should exclude closed/merged PRs",
18151815
owner: "microsoft",
18161816
repo: "vscode",
18171817
issueNumbers: []int{2},
1818-
includeClosedPrs: boolPtr(false),
1818+
includeClosedPrs: github.ToBoolPtr(false),
18191819
description: "Test includeClosedPrs=false parameter",
18201820
},
18211821
{
18221822
name: "orderByState=true - should order results by PR state",
18231823
owner: "microsoft",
18241824
repo: "vscode",
18251825
issueNumbers: []int{1, 2}, // Use low numbers for older issues
1826-
orderByState: boolPtr(true),
1826+
orderByState: github.ToBoolPtr(true),
18271827
description: "Test orderByState parameter with larger repository",
18281828
},
18291829
{
18301830
name: "userLinkedOnly=true - should return only manually linked PRs",
18311831
owner: "facebook",
18321832
repo: "react",
18331833
issueNumbers: []int{1}, // First issue in React repo
1834-
userLinkedOnly: boolPtr(true),
1834+
userLinkedOnly: github.ToBoolPtr(true),
18351835
description: "Test userLinkedOnly parameter",
18361836
},
18371837
{
18381838
name: "Combined boolean parameters",
18391839
owner: "facebook",
18401840
repo: "react",
18411841
issueNumbers: []int{1, 2},
1842-
includeClosedPrs: boolPtr(true),
1843-
orderByState: boolPtr(true),
1844-
userLinkedOnly: boolPtr(false),
1842+
includeClosedPrs: github.ToBoolPtr(true),
1843+
orderByState: github.ToBoolPtr(true),
1844+
userLinkedOnly: github.ToBoolPtr(false),
18451845
description: "Test multiple boolean parameters together",
18461846
},
18471847
}
@@ -1975,23 +1975,23 @@ func TestFindClosingPullRequestsGraphQLParameters(t *testing.T) {
19751975
owner: "microsoft",
19761976
repo: "vscode",
19771977
issueNumbers: []int{1, 2},
1978-
first: intPtr(1),
1978+
first: github.ToIntPtr(1),
19791979
description: "Test forward pagination using first parameter",
19801980
},
19811981
{
19821982
name: "Backward pagination with last parameter",
19831983
owner: "microsoft",
19841984
repo: "vscode",
19851985
issueNumbers: []int{1, 2},
1986-
last: intPtr(1),
1986+
last: github.ToIntPtr(1),
19871987
description: "Test backward pagination using last parameter",
19881988
},
19891989
{
19901990
name: "Large repository pagination test",
19911991
owner: "microsoft",
19921992
repo: "vscode",
19931993
issueNumbers: []int{1, 2, 3},
1994-
first: intPtr(1), // Small page size
1994+
first: github.ToIntPtr(1), // Small page size
19951995
description: "Test pagination with larger repository",
19961996
},
19971997
}
@@ -2235,16 +2235,3 @@ func TestFindClosingPullRequestsGraphQLParameters(t *testing.T) {
22352235
}
22362236
})
22372237
}
2238-
2239-
// Helper functions for pointer creation
2240-
func boolPtr(b bool) *bool {
2241-
return &b
2242-
}
2243-
2244-
func intPtr(i int) *int {
2245-
return &i
2246-
}
2247-
2248-
func stringPtr(s string) *string {
2249-
return &s
2250-
}

pkg/github/tools.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,11 @@ func ToBoolPtr(b bool) *bool {
213213
return &b
214214
}
215215

216+
// ToIntPtr converts an int to a *int pointer.
217+
func ToIntPtr(i int) *int {
218+
return &i
219+
}
220+
216221
// ToStringPtr converts a string to a *string pointer.
217222
// Returns nil if the string is empty.
218223
func ToStringPtr(s string) *string {

0 commit comments

Comments
 (0)