Skip to content

Commit

Permalink
Create content type constant
Browse files Browse the repository at this point in the history
  • Loading branch information
sbpann committed Jun 8, 2024
1 parent 5683eba commit a6d889e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
.coverage
.coverage

*.out
.scannerwork
7 changes: 7 additions & 0 deletions consts/http.const.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package consts

type HttpHeader string

const (
ContentType HttpHeader = "Content-Type"
)
11 changes: 6 additions & 5 deletions gin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"time"

. "github.com/argonlab-io/bucharest"
"github.com/argonlab-io/bucharest/consts"
"github.com/argonlab-io/bucharest/utils"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
Expand Down Expand Up @@ -297,7 +298,7 @@ func TestContentType(t *testing.T) {
if err != nil {
return false
}
req.Header.Set("Content-Type", gin.MIMEJSON)
req.Header.Set(string(consts.ContentType), gin.MIMEJSON)
res, err = client.Do(req)
return err == nil
}
Expand Down Expand Up @@ -868,7 +869,7 @@ func TestURLEncodedForm(t *testing.T) {
if err != nil {
return false
}
req.Header.Add("Content-Type", gin.MIMEPOSTForm)
req.Header.Add(string(consts.ContentType), gin.MIMEPOSTForm)

res, err = client.Do(req)
if res != nil {
Expand Down Expand Up @@ -963,7 +964,7 @@ func TestMultipartForm(t *testing.T) {
if err != nil {
return false
}
req.Header.Add("Content-Type", form.FormDataContentType())
req.Header.Add(string(consts.ContentType), form.FormDataContentType())

res, err = client.Do(req)
if res != nil {
Expand Down Expand Up @@ -1012,7 +1013,7 @@ func TestBinder(t *testing.T) {
if err != nil {
return false
}
req.Header.Set("Content-Type", gin.MIMEJSON)
req.Header.Set(string(consts.ContentType), gin.MIMEJSON)
res, err = client.Do(req)
if res != nil {
assert.NoError(t, err)
Expand Down Expand Up @@ -1065,7 +1066,7 @@ func TestBinder(t *testing.T) {
return false
}

req.Header.Set("Content-Type", gin.MIMEXML)
req.Header.Set(string(consts.ContentType), gin.MIMEXML)
res, err = client.Do(req)
if res != nil {
assert.NoError(t, err)
Expand Down

0 comments on commit a6d889e

Please sign in to comment.