[HN Gopher] Writing and testing a paginated API iterator in Go
       ___________________________________________________________________
        
       Writing and testing a paginated API iterator in Go
        
       Author : thiht
       Score  : 58 points
       Date   : 2024-12-20 12:55 UTC (3 days ago)
        
 (HTM) web link (blog.thibaut-rousseau.com)
 (TXT) w3m dump (blog.thibaut-rousseau.com)
        
       | ivanvanderbyl wrote:
       | I'm incredibly excited about using this, thanks for the excellent
       | write up.
        
         | rollulus wrote:
         | Same here. Haven't looked into Go iterators because I couldn't
         | find a purpose, but trying them in our SDK for pagination was
         | on my list. Great.
        
       | Joker_vD wrote:
       | Uhm, is passing opts by pointer, as
       | "*github.RepositoryListByUserOptions" instead of by value
       | intended? I suppose it can be used to resume the iteration from
       | where it was stopped?
        
       | dhuan_ wrote:
       | that's a really useful testing strategy. I used to to write
       | automated tests using an approach very similar to yours, but I
       | was often bothered that I needed to write code in a programming
       | language to set up the mocked data. After a while the testing
       | code gets really verbose. Not just the mocking setup but also the
       | assertion logic. I wanted an easier way that didn't involve
       | writing much code, so I ended up building "mock":
       | 
       | https://dhuan.github.io/mock/
        
       ___________________________________________________________________
       (page generated 2024-12-23 23:01 UTC)