From 943a776e8572aaa5efc67fc4a01c164039c5931c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Lewandowski?= Date: Thu, 23 May 2024 10:46:32 +0200 Subject: [PATCH] chore(SPV-804): fix tests --- admin_contacts_test.go | 8 +++++--- contacts_test.go | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/admin_contacts_test.go b/admin_contacts_test.go index 610d0fa..8ddeff1 100644 --- a/admin_contacts_test.go +++ b/admin_contacts_test.go @@ -19,8 +19,10 @@ func TestAdminContactActions(t *testing.T) { case r.URL.Path == "/v1/admin/contact/search" && r.Method == http.MethodPost: c := fixtures.Contact c.ID = "1" - contacts := []*models.Contact{c} - json.NewEncoder(w).Encode(contacts) + content := models.PagedResponse[*models.Contact]{ + Content: []*models.Contact{c}, + } + json.NewEncoder(w).Encode(content) case r.URL.Path == "/v1/admin/contact/1" && r.Method == http.MethodPatch: contact := fixtures.Contact json.NewEncoder(w).Encode(contact) @@ -46,7 +48,7 @@ func TestAdminContactActions(t *testing.T) { t.Run("AdminGetContacts", func(t *testing.T) { contacts, err := client.AdminGetContacts(context.Background(), nil, nil, nil) require.NoError(t, err) - require.Equal(t, "1", contacts[0].ID) + require.Equal(t, "1", contacts.Content[0].ID) }) t.Run("AdminUpdateContact", func(t *testing.T) { diff --git a/contacts_test.go b/contacts_test.go index 1d10411..4f6b0ba 100644 --- a/contacts_test.go +++ b/contacts_test.go @@ -28,7 +28,10 @@ func TestContactActionsRouting(t *testing.T) { } case r.URL.Path == "/v1/contact/search": if r.Method == http.MethodPost { - json.NewEncoder(w).Encode([]*models.Contact{fixtures.Contact}) + content := models.PagedResponse[*models.Contact]{ + Content: []*models.Contact{fixtures.Contact}, + } + json.NewEncoder(w).Encode(content) } case strings.HasPrefix(r.URL.Path, "/v1/contact/"): if r.Method == http.MethodPost || r.Method == http.MethodPut {