|
| 1 | +package porcelain |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "net/http" |
| 6 | + "net/http/httptest" |
| 7 | + "net/url" |
| 8 | + "testing" |
| 9 | + |
| 10 | + "github.com/go-openapi/runtime" |
| 11 | + apiClient "github.com/go-openapi/runtime/client" |
| 12 | + "github.com/go-openapi/strfmt" |
| 13 | + apiContext "github.com/netlify/open-api/go/porcelain/context" |
| 14 | + "github.com/stretchr/testify/require" |
| 15 | +) |
| 16 | + |
| 17 | +func TestListFormsBySiteId(t *testing.T) { |
| 18 | + server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { |
| 19 | + rw.Header().Set("Content-Type", "application/json; charset=utf-8") |
| 20 | + rw.Write([]byte(`[]`)) |
| 21 | + })) |
| 22 | + defer server.Close() |
| 23 | + |
| 24 | + httpClient := http.DefaultClient |
| 25 | + |
| 26 | + authInfo := runtime.ClientAuthInfoWriterFunc(func(r runtime.ClientRequest, _ strfmt.Registry) error { |
| 27 | + r.SetHeaderParam("User-Agent", "buildbot") |
| 28 | + r.SetHeaderParam("Authorization", "Bearer 1234") |
| 29 | + return nil |
| 30 | + }) |
| 31 | + |
| 32 | + parsedURL, err := url.Parse(server.URL) |
| 33 | + require.NoError(t, err) |
| 34 | + tr := apiClient.NewWithClient(parsedURL.Host, "/api/v1", []string{"http"}, httpClient) |
| 35 | + client := NewRetryable(tr, strfmt.Default, 1) |
| 36 | + _, err = client.ListFormsBySiteId(apiContext.WithAuthInfo(context.Background(), authInfo), "123") |
| 37 | + require.NoError(t, err) |
| 38 | +} |
0 commit comments