#51 | Refactored name for getPrimaryEmailAddress auxiliary method

This commit is contained in:
Andres De Castro
2017-11-13 14:46:45 +02:00
parent ceb1876417
commit aa8743d345
2 changed files with 5 additions and 4 deletions
+4 -3
View File
@@ -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
},
+1 -1
View File
@@ -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