|
| 1 | +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +package gitpod_test |
| 4 | + |
| 5 | +import ( |
| 6 | + "context" |
| 7 | + "os" |
| 8 | + "testing" |
| 9 | + |
| 10 | + "github.com/stainless-sdks/gitpod-go" |
| 11 | + "github.com/stainless-sdks/gitpod-go/internal/testutil" |
| 12 | + "github.com/stainless-sdks/gitpod-go/option" |
| 13 | +) |
| 14 | + |
| 15 | +func TestManualPagination(t *testing.T) { |
| 16 | + baseURL := "http://localhost:4010" |
| 17 | + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { |
| 18 | + baseURL = envURL |
| 19 | + } |
| 20 | + if !testutil.CheckTestServer(t, baseURL) { |
| 21 | + return |
| 22 | + } |
| 23 | + client := gitpod.NewClient( |
| 24 | + option.WithBaseURL(baseURL), |
| 25 | + option.WithBearerToken("My Bearer Token"), |
| 26 | + ) |
| 27 | + page, err := client.Environments.Automations.Services.List(context.TODO(), gitpod.EnvironmentAutomationServiceListParams{}) |
| 28 | + if err != nil { |
| 29 | + t.Fatalf("err should be nil: %s", err.Error()) |
| 30 | + } |
| 31 | + for _, service := range page.Pagination.PersonalAccessTokens { |
| 32 | + t.Logf("%+v\n", service.Pagination) |
| 33 | + } |
| 34 | + // Prism mock isn't going to give us real pagination |
| 35 | + page, err = page.GetNextPage() |
| 36 | + if err != nil { |
| 37 | + t.Fatalf("err should be nil: %s", err.Error()) |
| 38 | + } |
| 39 | + if page != nil { |
| 40 | + for _, service := range page.Pagination.PersonalAccessTokens { |
| 41 | + t.Logf("%+v\n", service.Pagination) |
| 42 | + } |
| 43 | + } |
| 44 | +} |
0 commit comments