Skip to content

Commit 9271230

Browse files
committed
Add more assertions to ListFormsBySiteId test
1 parent cdf09ac commit 9271230

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

go/porcelain/forms_test.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,26 @@ import (
1111
apiClient "github.com/go-openapi/runtime/client"
1212
"github.com/go-openapi/strfmt"
1313
apiContext "github.com/netlify/open-api/go/porcelain/context"
14+
"github.com/stretchr/testify/assert"
1415
"github.com/stretchr/testify/require"
1516
)
1617

1718
func TestListFormsBySiteId(t *testing.T) {
1819
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
1920
rw.Header().Set("Content-Type", "application/json; charset=utf-8")
20-
rw.Write([]byte(`[]`))
21+
rw.Write([]byte(`
22+
[
23+
{
24+
"id": "1",
25+
"site_id": "123",
26+
"name": "contact",
27+
"paths": [],
28+
"submission_count": 0,
29+
"fields": [],
30+
"created_at": ""
31+
}
32+
]`))
33+
assert.Equal(t, "/api/v1/sites/123/forms", req.URL.String())
2134
}))
2235
defer server.Close()
2336

@@ -33,6 +46,7 @@ func TestListFormsBySiteId(t *testing.T) {
3346
require.NoError(t, err)
3447
tr := apiClient.NewWithClient(parsedURL.Host, "/api/v1", []string{"http"}, httpClient)
3548
client := NewRetryable(tr, strfmt.Default, 1)
36-
_, err = client.ListFormsBySiteId(apiContext.WithAuthInfo(context.Background(), authInfo), "123")
49+
forms, err := client.ListFormsBySiteId(apiContext.WithAuthInfo(context.Background(), authInfo), "123")
3750
require.NoError(t, err)
51+
assert.Equal(t, len(forms), 1)
3852
}

0 commit comments

Comments
 (0)