From e289cffba572e28ac5ab82a9866775780abd3fa1 Mon Sep 17 00:00:00 2001 From: Pavel Date: Thu, 1 Feb 2024 15:58:51 +0300 Subject: [PATCH] add test --- internal/interface/swagger/api.gen.go | 2 +- tests/e2e/changeAccount_test.go | 4 ++++ tests/e2e/getAccount_test.go | 33 ++++++++++++++++++++++++++- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/internal/interface/swagger/api.gen.go b/internal/interface/swagger/api.gen.go index fa1bfb6..7d5fb62 100644 --- a/internal/interface/swagger/api.gen.go +++ b/internal/interface/swagger/api.gen.go @@ -410,7 +410,7 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL router.GET(baseURL+"/account/:userId", wrapper.GetDirectAccount) router.PATCH(baseURL+"/account/:userId", wrapper.SetAccountVerificationStatus) router.GET(baseURL+"/accounts", wrapper.PaginationAccounts) - router.DELETE(baseURL+"/cart", wrapper.RemoveFromCart) + router.DELETE(baseURL+"/cart", wrapper.RemoveFromCart)//- router.PATCH(baseURL+"/cart", wrapper.Add2cart) router.POST(baseURL+"/cart/pay", wrapper.PayCart) router.GET(baseURL+"/currencies", wrapper.GetCurrencies) diff --git a/tests/e2e/changeAccount_test.go b/tests/e2e/changeAccount_test.go index 026d083..bcfcea9 100644 --- a/tests/e2e/changeAccount_test.go +++ b/tests/e2e/changeAccount_test.go @@ -49,6 +49,10 @@ func TestChangeAccount(t *testing.T) { assert.Equal(t, "Adios payasos", responseChangeAccount.Body.Name.Orgname) assert.Equal(t, "payasos", responseChangeAccount.Body.Name.Secondname) }) + }) + t.Run("Установить статус аккаунта", func(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() assert.NotPanics(t, func() { token, tokenErr := jwtUtil.Create("64e5d9830fcca0596d82c0c7") if isNoError := assert.NoError(t, tokenErr); !isNoError { diff --git a/tests/e2e/getAccount_test.go b/tests/e2e/getAccount_test.go index a5d74f0..4038444 100644 --- a/tests/e2e/getAccount_test.go +++ b/tests/e2e/getAccount_test.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "github.com/stretchr/testify/assert" + "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/swagger" "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/client" "penahub.gitlab.yandexcloud.net/pena-services/customer/tests/helpers" @@ -36,7 +37,10 @@ func TestGetAccount(t *testing.T) { assert.Equal(t, "64e5d9830fcca0596d82c0c7", responseGetAccount.Body.UserID) }) - + }) + t.Run("Получение аккаунта юзера по id", func(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() assert.NotPanics(t, func() { token, tokenErr := jwtUtil.Create("64e5d9830fcca0596d82c0c7") if isNoError := assert.NoError(t, tokenErr); !isNoError { @@ -57,4 +61,31 @@ func TestGetAccount(t *testing.T) { assert.Equal(t, "64e5d9830fcca0596d82c0c7", responseGetAccount.Body.UserID) }) }) + t.Run("Получение аккаунтов с пагинацией", func(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + assert.NotPanics(t, func() { + + page := 0 + limit := 3 + + params := swagger.PaginationAccountsParams{ + Page: &page, + Limit: &limit, + } + + responseGetAccount, errGetAccount := client.Get[models.PaginationResponse[models.Account], models.ResponseErrorHTTP](ctx, &client.RequestSettings{ + URL: "http://localhost:8000/accounts", + Body: params, + }) + if isNoError := assert.NoError(t, errGetAccount); !isNoError { + return + } + if isNoRequestError := assert.Nil(t, responseGetAccount.Error); !isNoRequestError { + return + } + + fmt.Println(responseGetAccount.Body) + }) + }) }