@@ -19,11 +19,49 @@ func TestFindPR(t *testing.T) {
1919 c := github .NewClient (hc )
2020 ctx := context .Background ()
2121
22- // https://github.com/elastic/elastic-agent-changelog-tool/commit/9c995a2e397d346e68ea5052c54bcbd0f8b142ad
23- res , err := github .FindPR (ctx , c , "elastic" , "elastic-agent-changelog-tool" , "9c995a2e397d346e68ea5052c54bcbd0f8b142ad" )
22+ // This is a PR merged on trunk:
23+ // https://github.com/elastic/beats/pull/30859
24+ // https://github.com/elastic/beats/commit/56df883ca93b11816206dad401c49a2c96fa268d
25+ res , err := github .FindPR (ctx , c , "elastic" , "beats" , "56df883ca93b11816206dad401c49a2c96fa268d" )
2426 require .NoError (t , err )
2527 require .Len (t , res .Items , 1 )
26- require .Equal (t , res .Items [0 ].PullRequestID , 30 )
28+ require .Equal (t , 30859 , res .Items [0 ].PullRequestID )
29+ }
30+
31+ func TestFindPR_backport (t * testing.T ) {
32+ r , hc := getHttpClient (t )
33+ defer r .Stop () //nolint:errcheck
34+
35+ c := github .NewClient (hc )
36+ ctx := context .Background ()
37+
38+ // This is a merge commit of a backport from main to 8.1:
39+ // from https://github.com/elastic/beats/pull/31279 to https://github.com/elastic/beats/pull/31343
40+ // https://github.com/elastic/beats/commit/fe25c73907336fc462d5e6e059d3cd86512484fe
41+ res , err := github .FindPR (ctx , c , "elastic" , "beats" , "fe25c73907336fc462d5e6e059d3cd86512484fe" )
42+ require .NoError (t , err )
43+ require .Len (t , res .Items , 4 )
44+ require .Equal (t , 31396 , res .Items [0 ].PullRequestID )
45+ require .Equal (t , 31417 , res .Items [1 ].PullRequestID )
46+ require .Equal (t , 31382 , res .Items [2 ].PullRequestID )
47+ require .Equal (t , 31343 , res .Items [3 ].PullRequestID )
48+ }
49+
50+ func TestFindPR_forwardport (t * testing.T ) {
51+ t .Skip ("this behaviour is not yet implemented" )
52+ r , hc := getHttpClient (t )
53+ defer r .Stop () //nolint:errcheck
54+
55+ c := github .NewClient (hc )
56+ ctx := context .Background ()
57+
58+ // This is a merge commit of a forwardport from 8.0 to main:
59+ // from https://github.com/elastic/beats/issues/29209 to https://github.com/elastic/beats/pull/30626
60+ // https://github.com/elastic/beats/commit/8800e5f6ad5beb024dee141a2639630b79a99a37
61+ res , err := github .FindPR (ctx , c , "elastic" , "beats" , "8800e5f6ad5beb024dee141a2639630b79a99a37" )
62+ require .NoError (t , err )
63+ require .Len (t , res .Items , 1 )
64+ require .Equal (t , 29209 , res .Items [0 ].PullRequestID )
2765}
2866
2967func TestFindPR_missingCommit (t * testing.T ) {
0 commit comments