From aa12aa8283456d6368c12fc7d4ae869ff7b4e734 Mon Sep 17 00:00:00 2001 From: bbrodriges Date: Fri, 5 Apr 2024 18:10:15 +0300 Subject: [PATCH] fix shortenertestbeta iter15 --- cmd/shortenertestbeta/iteration15_test.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cmd/shortenertestbeta/iteration15_test.go b/cmd/shortenertestbeta/iteration15_test.go index 65e9704..16bb59d 100644 --- a/cmd/shortenertestbeta/iteration15_test.go +++ b/cmd/shortenertestbeta/iteration15_test.go @@ -12,13 +12,12 @@ import ( "syscall" "time" + "github.com/Yandex-Practicum/go-autotests/internal/fork" "github.com/go-resty/resty/v2" "github.com/jackc/pgx" "github.com/jackc/pgx/stdlib" "github.com/stretchr/testify/suite" "golang.org/x/sync/errgroup" - - "github.com/Yandex-Practicum/go-autotests/internal/fork" ) // Iteration15Suite является сьютом с тестами и состоянием для инкремента @@ -151,6 +150,8 @@ func (suite *Iteration15Suite) TestDelete() { SetCookieJar(jar). SetRedirectPolicy(redirPolicy) + var authorizationHeader string + shortenURLs := make(map[string]string) suite.Run("shorten", func() { @@ -182,6 +183,9 @@ func (suite *Iteration15Suite) TestDelete() { dump := dumpRequest(req.RawRequest, true) suite.T().Logf("Оригинальный запрос:\n\n%s", dump) } + + // сохраняем заголовок Authorization если он есть + authorizationHeader = resp.Header().Get("Authorization") } }) @@ -204,6 +208,12 @@ func (suite *Iteration15Suite) TestDelete() { SetContext(ctx). SetHeader("Content-Type", "application/json"). SetBody(body) + + // устанавливаем заголовок Authorization, есчли у нас есть токен + if authorizationHeader != "" { + req.SetHeader("Authorization", authorizationHeader) + } + resp, err := req.Delete("/api/user/urls") noRespErr := suite.Assert().NoError(err, "Ошибка при попытке сделать запрос для удаления URL")