Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor tweaks in [github] auth code #1862

Merged
merged 8 commits into from
Aug 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/token-pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,12 @@ class TokenPool {
this.fifoQueue.forEach(visit)
this.priorityQueue.forEach(visit)
}

allValidTokenIds() {
const result = []
this.forEach(({ id }) => result.push(id))
return result
}
}

module.exports = {
Expand Down
4 changes: 4 additions & 0 deletions lib/token-pool.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ describe('The token pool', function() {
ids.forEach(id => tokenPool.add(id))
})

it('allValidTokenIds() should return the full list', function() {
expect(tokenPool.allValidTokenIds()).to.deep.equal(ids)
})

it('should yield the expected tokens', function() {
ids.forEach(id =>
times(batchSize, () => expect(tokenPool.next().id).to.equal(id))
Expand Down
8 changes: 1 addition & 7 deletions lib/token-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,7 @@ class PoolingTokenProvider {

// Return an array of token strings.
toNative() {
const result = []

this.tokenPool.forEach(token => {
result.push(token.id)
})

return result
return this.tokenPool.allValidTokenIds()
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/token-provider.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const assert = require('assert')
const { PoolingTokenProvider } = require('./token-provider')
const isValidGithubToken = require('./github-auth/is-valid-token')
const isValidGithubToken = require('../services/github/auth/is-valid-token')

describe('The token provider', function() {
describe('toNative', function() {
Expand Down
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3190,10 +3190,10 @@ cache(function(data, match, sendBadge, request) {
var allReleases = match[2];
var format = match[3];
let apiUrl = `/repos/${userRepo}/releases`;
var badgeData = getBadgeData('release', data);
if (allReleases === undefined) {
apiUrl = apiUrl + '/latest';
}
var badgeData = getBadgeData('release', data);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure how this change is relevant to this pull request?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I came across it because it’s in the middle of a github badge affected by #1861.

if (badgeData.template === 'social') {
badgeData.logo = getLogo('github', data);
}
Expand Down