Skip to content

Commit

Permalink
fix shortenertestbeta iter15
Browse files Browse the repository at this point in the history
  • Loading branch information
bbrodriges committed Apr 5, 2024
1 parent 61a10e4 commit aa12aa8
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions cmd/shortenertestbeta/iteration15_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 является сьютом с тестами и состоянием для инкремента
Expand Down Expand Up @@ -151,6 +150,8 @@ func (suite *Iteration15Suite) TestDelete() {
SetCookieJar(jar).
SetRedirectPolicy(redirPolicy)

var authorizationHeader string

shortenURLs := make(map[string]string)

suite.Run("shorten", func() {
Expand Down Expand Up @@ -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")
}
})

Expand All @@ -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")
Expand Down

0 comments on commit aa12aa8

Please sign in to comment.