generated from PenaSide/GolangTemplate
add test
This commit is contained in:
parent
4c2e997cb8
commit
e289cffba5
@ -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)
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user