From aa8743d345c4c55f5b3a11144f89776de62529d5 Mon Sep 17 00:00:00 2001 From: Andres De Castro Date: Mon, 13 Nov 2017 14:46:45 +0200 Subject: [PATCH] #51 | Refactored name for getPrimaryEmailAddress auxiliary method --- oauth2/bitbucket.go | 7 ++++--- oauth2/bitbucket_test.go | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/oauth2/bitbucket.go b/oauth2/bitbucket.go index 16eb1a4..4124e3d 100644 --- a/oauth2/bitbucket.go +++ b/oauth2/bitbucket.go @@ -10,6 +10,7 @@ import ( ) var bitbucketAPI = "https://api.bitbucket.org/2.0" + // Using the avatar url to be able to fetch 128px image. By default BitbucketAPI return 32px image. var bitbucketAvatarURL = "https://bitbucket.org/account/%v/avatar/128/" @@ -45,8 +46,8 @@ type email struct { Type string `json:"type,omitempty"` } -// GetPrimaryEmailAddress retrieve the primary email address of the user -func (e *emails) GetPrimaryEmailAddress() string { +// getPrimaryEmailAddress retrieve the primary email address of the user +func (e *emails) getPrimaryEmailAddress() string { for _, val := range e.Values { if val.IsPrimary { return val.Email @@ -124,7 +125,7 @@ var providerBitbucket = Provider{ Sub: gu.Username, Picture: fmt.Sprintf(bitbucketAvatarURL, gu.Username), Name: gu.DisplayName, - Email: userEmails.GetPrimaryEmailAddress(), + Email: userEmails.getPrimaryEmailAddress(), Origin: "bitbucket", }, string(b), nil }, diff --git a/oauth2/bitbucket_test.go b/oauth2/bitbucket_test.go index 9173feb..e097c4c 100644 --- a/oauth2/bitbucket_test.go +++ b/oauth2/bitbucket_test.go @@ -123,7 +123,7 @@ func (suite *BitbucketTestSuite) Test_Bitbucket_getPrimaryEmailAddress() { userEmails := emails{} err := json.Unmarshal([]byte(bitbucketTestUserEmailResponse), &userEmails) suite.NoError(err) - suite.Equal("tutorials@bitbucket.com", userEmails.GetPrimaryEmailAddress()) + suite.Equal("tutorials@bitbucket.com", userEmails.getPrimaryEmailAddress()) } // Test_Bitbucket_Suite Runs the entire suite for Bitbucket