package gitlab import "testing" var nextURLTests = []struct { link string expected string }{ {"; rel=\"next\", " + "; rel=\"prev\"; pet=\"cat\", " + "; rel=\"last\"", "https://gitlab.com/api/v4/groups?page=2&per_page=20"}, {"; rel=\"next\", " + "; rel=\"prev\"; pet=\"dog\", " + "; rel=\"last\"", "https://gitlab.com/api/v4/groups?page=3&per_page=20"}, {"; rel=\"prev\"; pet=\"bunny\", " + "; rel=\"last\"", ""}, } func TestNextURL(t *testing.T) { apiURL := "https://gitlab.com/api/v4/groups" for _, tt := range nextURLTests { apiURL = nextURL(apiURL, tt.link) if apiURL != tt.expected { t.Errorf("Should have returned %s, got %s", tt.expected, apiURL) } } }