customer/tests/e2e/сurrencies_test.go

42 lines
1.2 KiB
Go
Raw Normal View History

2024-02-01 13:48:29 +00:00
package e2e_test
import (
"context"
"fmt"
"github.com/stretchr/testify/assert"
"net/http"
2024-11-18 07:23:41 +00:00
"gitea.pena/PenaSide/customer/internal/models"
"gitea.pena/PenaSide/customer/pkg/client"
"gitea.pena/PenaSide/customer/tests/helpers"
2024-02-01 13:48:29 +00:00
"testing"
)
func TestCurrencies(t *testing.T) {
2024-05-20 14:29:45 +00:00
jwtUtil := helpers.InitializeJWT()
2024-02-01 13:48:29 +00:00
t.Run("Получение текущих доступных курсов", func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
assert.NotPanics(t, func() {
2024-05-20 14:29:45 +00:00
token, tokenErr := jwtUtil.Create("6597babdd1ba7e2dbd32d7e3")
if isNoError := assert.NoError(t, tokenErr); !isNoError {
return
}
2024-02-01 13:48:29 +00:00
responseGetCurrencies, errCurrencies := client.Get[[]models.CurrencyList, models.ResponseErrorHTTP](ctx, &client.RequestSettings{
2024-05-20 14:29:45 +00:00
URL: "http://localhost:8082/currencies",
Headers: map[string]string{"Authorization": fmt.Sprintf("Bearer %s", token)},
2024-02-01 13:48:29 +00:00
})
if isNoError := assert.NoError(t, errCurrencies); !isNoError {
return
}
if isNoRequestError := assert.Nil(t, responseGetCurrencies.Error); !isNoRequestError {
return
}
fmt.Println(responseGetCurrencies.Body)
assert.Equal(t, http.StatusOK, responseGetCurrencies.StatusCode)
})
})
}