@@ -33,13 +33,15 @@ func TestGithubExporter(t *testing.T) {
3333 githubRepos (),
3434 githubRateLimit (),
3535 githubReleases (),
36+ githubPulls (),
3637 ).
3738 Get ("/metrics" ).
3839 Expect (t ).
3940 Assert (bodyContains (`github_rate_limit 60` )).
4041 Assert (bodyContains (`github_rate_remaining 60` )).
4142 Assert (bodyContains (`github_rate_reset 1.566853865e+09` )).
4243 Assert (bodyContains (`github_repo_forks{archived="false",fork="false",language="Go",license="mit",private="false",repo="myRepo",user="myOrg"} 10` )).
44+ Assert (bodyContains (`github_repo_pull_request_count 3` )).
4345 Assert (bodyContains (`github_repo_open_issues{archived="false",fork="false",language="Go",license="mit",private="false",repo="myRepo",user="myOrg"} 2` )).
4446 Assert (bodyContains (`github_repo_size_kb{archived="false",fork="false",language="Go",license="mit",private="false",repo="myRepo",user="myOrg"} 946` )).
4547 Assert (bodyContains (`github_repo_stars{archived="false",fork="false",language="Go",license="mit",private="false",repo="myRepo",user="myOrg"} 120` )).
@@ -105,6 +107,17 @@ func githubReleases() *apitest.Mock {
105107 End ()
106108}
107109
110+ func githubPulls () * apitest.Mock {
111+ return apitest .NewMock ().
112+ Get ("https://api.github.com/repos/myOrg/myRepo/pulls" ).
113+ Header ("Authorization" , "token 12345" ).
114+ RespondWith ().
115+ Times (2 ).
116+ Body (readFile ("testdata/pulls_response.json" )).
117+ Status (http .StatusOK ).
118+ End ()
119+ }
120+
108121func readFile (path string ) string {
109122 bytes , err := ioutil .ReadFile (path )
110123 if err != nil {
0 commit comments