-
Notifications
You must be signed in to change notification settings - Fork 0
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just comments about comments pretty much.
@@ -86,7 +86,11 @@ def bin(name_or_regex) | |||
|
|||
def bins | |||
@bins ||= begin | |||
get('/bins?max-results=500').map do |bin_data| | |||
per_page = 500 | |||
data = (0..1).inject([]) do |list, page| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this breaks when I add 450 more bins? Sounds good. Can you make it break harder so if we have 1000 bins we're forced to move away…as a failsafe?
get('/bins?max-results=500').map do |bin_data| | ||
per_page = 500 | ||
data = (0..1).inject([]) do |list, page| | ||
list += get("/bins?max-results=#{per_page}&page-token=#{page * 500}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, their API is a bit odd…page-token
what does that mean?
Assuming it works.
end | ||
data.map do |bin_data| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I might suggest this and discarding the data
constant altogether. In Javascript I would, but alas. Ignore me!
end | |
data.map do |bin_data| | |
.map do |bin_data| |
@@ -181,11 +181,15 @@ class ClientTest < Minitest::Test | |||
client = Vimaly::Client.new('company_id', user_credentials: { username: 'username', password: 'password' }) | |||
bins = client.bins | |||
|
|||
assert_equal 2, bins.size | |||
assert_equal 4, bins.size # API called twice now (2 pages) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, so our Mocked API is returning [Alpha, Beta]
for both requests? Eg. page=2
is still returning [Alpha, Beta]
? Clearly a fake mock, but works for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something a bit more? Out-of-context I think it's confusing.
assert_equal 4, bins.size # API called twice now (2 pages) | |
# API called twice now (2x pages returning a mocked result of 2 bins) | |
assert_equal 4, bins.size |
No description provided.