Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add content types to requests #72

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/metricstest/iteration12_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ func (suite *Iteration12Suite) TestBatchAPI() {
},
}

req := httpc.R()
req := httpc.R().
SetHeader("Content-Type", "application/json")
resp, err := req.SetBody(metrics).
Post("updates/")

Expand Down
24 changes: 16 additions & 8 deletions cmd/metricstest/iteration1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ func (suite *Iteration1Suite) TestGaugeHandlers() {
httpc := resty.New().SetHostURL(suite.serverAddress)

suite.Run("update", func() {
req := httpc.R()
req := httpc.R().
SetHeader("Content-Type", "plain/text")
resp, err := req.Post("update/gauge/testGauge/100")

noRespErr := suite.Assert().NoError(err,
Expand All @@ -108,7 +109,8 @@ func (suite *Iteration1Suite) TestGaugeHandlers() {
})

suite.Run("without id", func() {
req := httpc.R()
req := httpc.R().
SetHeader("Content-Type", "plain/text")
resp, err := req.Post("update/gauge/")

noRespErr := suite.Assert().NoError(err,
Expand All @@ -124,7 +126,8 @@ func (suite *Iteration1Suite) TestGaugeHandlers() {
})

suite.Run("invalid value", func() {
req := httpc.R()
req := httpc.R().
SetHeader("Content-Type", "plain/text")
resp, err := req.Post("update/gauge/testGauge/none")

noRespErr := suite.Assert().NoError(err,
Expand All @@ -144,7 +147,8 @@ func (suite *Iteration1Suite) TestCounterHandlers() {
httpc := resty.New().SetHostURL(suite.serverAddress)

suite.Run("update", func() {
req := httpc.R()
req := httpc.R().
SetHeader("Content-Type", "plain/text")
resp, err := req.Post("update/counter/testCounter/100")

noRespErr := suite.Assert().NoError(err,
Expand All @@ -160,7 +164,8 @@ func (suite *Iteration1Suite) TestCounterHandlers() {
})

suite.Run("without id", func() {
req := httpc.R()
req := httpc.R().
SetHeader("Content-Type", "plain/text")
resp, err := req.Post("update/counter/")

noRespErr := suite.Assert().NoError(err,
Expand All @@ -176,7 +181,8 @@ func (suite *Iteration1Suite) TestCounterHandlers() {
})

suite.Run("invalid value", func() {
req := httpc.R()
req := httpc.R().
SetHeader("Content-Type", "plain/text")
resp, err := req.Post("update/counter/testCounter/none")

noRespErr := suite.Assert().NoError(err,
Expand All @@ -196,7 +202,8 @@ func (suite *Iteration1Suite) TestUnknownHandlers() {
httpc := resty.New().SetHostURL(suite.serverAddress)

suite.Run("update invalid type", func() {
req := httpc.R()
req := httpc.R().
SetHeader("Content-Type", "plain/text")
resp, err := req.Post("update/unknown/testCounter/100")

noRespErr := suite.Assert().NoError(err,
Expand All @@ -212,7 +219,8 @@ func (suite *Iteration1Suite) TestUnknownHandlers() {
})

suite.Run("update invalid method", func() {
req := httpc.R()
req := httpc.R().
SetHeader("Content-Type", "plain/text")
resp, err := req.Post("updater/counter/testCounter/100")

noRespErr := suite.Assert().NoError(err,
Expand Down
1 change: 1 addition & 0 deletions cmd/shortenertestbeta/iteration11_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func (suite *Iteration11Suite) TestInspectDatabase() {

req := httpc.R().
SetContext(ctx).
SetHeader("Content-Type", "plain/text").
SetBody(originalURL)
_, err := req.Post("/")
noRespErr := suite.Assert().NoError(err, "Ошибка при попытке сделать запрос для сокращения URL")
Expand Down
1 change: 1 addition & 0 deletions cmd/shortenertestbeta/iteration13_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ func (suite *Iteration13Suite) TestConflict() {

req := httpc.R().
SetContext(ctx).
SetHeader("Content-Type", "plain/text").
SetBody(originalURL)
resp, err := req.Post("/")

Expand Down
1 change: 1 addition & 0 deletions cmd/shortenertestbeta/iteration14_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func (suite *Iteration14Suite) TestAuth() {

req := httpc.R().
SetContext(ctx).
SetHeader("Content-Type", "plain/text").
SetBody(originalURL)
resp, err := req.Post("/")

Expand Down
2 changes: 2 additions & 0 deletions cmd/shortenertestbeta/iteration15_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ func (suite *Iteration15Suite) TestDelete() {

req := httpc.R().
SetContext(ctx).
SetHeader("Content-Type", "plain/text").
SetBody(originalURL)
resp, err := req.Post("/")

Expand Down Expand Up @@ -287,6 +288,7 @@ func (suite *Iteration15Suite) TestDeleteConcurrent() {

req := httpc.R().
SetContext(ctx).
SetHeader("Content-Type", "plain/text").
SetBody(originalURL)
resp, err := req.Post("/")

Expand Down
1 change: 1 addition & 0 deletions cmd/shortenertestbeta/iteration1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func (suite *Iteration1Suite) TestHandlers() {
// делаем запрос к серверу для сокращения URL
req := httpc.R().
SetContext(ctx).
SetHeader("Content-Type", "plain/text").
SetBody(originalURL)
resp, err := req.Post("/")

Expand Down
1 change: 1 addition & 0 deletions cmd/shortenertestbeta/iteration4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func (suite *Iteration4Suite) TestFlags() {

req := httpc.R().
SetContext(ctx).
SetHeader("Content-Type", "plain/text").
SetBody(originalURL)
resp, err := req.Post("/")

Expand Down
1 change: 1 addition & 0 deletions cmd/shortenertestbeta/iteration5_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ func (suite *Iteration5Suite) TestEnvVars() {

req := httpc.R().
SetContext(ctx).
SetHeader("Content-Type", "plain/text").
SetBody(originalURL)
resp, err := req.Post("/")

Expand Down
1 change: 1 addition & 0 deletions cmd/shortenertestbeta/iteration8_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func (suite *Iteration8Suite) TestGzipCompress() {
req := httpc.R().
SetContext(ctx).
SetBody(buf.Bytes()).
SetHeader("Content-Type", "plain/text").
SetHeader("Accept-Encoding", "gzip").
SetHeader("Content-Encoding", "gzip")
resp, err := req.Post("/")
Expand Down
1 change: 1 addition & 0 deletions cmd/shortenertestbeta/iteration9_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func (suite *Iteration9Suite) TestPersistentFile() {
suite.Run("shorten", func() {
req := httpc.R().
SetContext(ctx).
SetHeader("Content-Type", "plain/text").
SetBody(originalURL)
resp, err := req.Post("/")

Expand Down