Skip to content

Commit

Permalink
add more uts
Browse files Browse the repository at this point in the history
  • Loading branch information
Skyenought committed Nov 7, 2023
1 parent 22cc5c9 commit 40ce982
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions pkg/app/server/hertz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"context"
"errors"
"fmt"
"github.com/cloudwego/hertz/pkg/common/ut"

Check failure on line 24 in pkg/app/server/hertz_test.go

View workflow job for this annotation

GitHub Actions / lint-and-ut (1.18)

File is not `gofumpt`-ed (gofumpt)

Check failure on line 24 in pkg/app/server/hertz_test.go

View workflow job for this annotation

GitHub Actions / lint-and-ut (1.19)

File is not `gofumpt`-ed (gofumpt)

Check failure on line 24 in pkg/app/server/hertz_test.go

View workflow job for this annotation

GitHub Actions / lint-and-ut (1.20)

File is not `gofumpt`-ed (gofumpt)
"github.com/cloudwego/hertz/pkg/route"
"html/template"
"io"
"io/ioutil"
Expand Down Expand Up @@ -1066,3 +1068,28 @@ func TestValidateConfigAndBindConfig(t *testing.T) {
assert.Nil(t, err)
time.Sleep(100 * time.Millisecond)
}

func TestWithDisableDefaultDate(t *testing.T) {
engine := route.NewEngine(config.NewOptions([]config.Option{
WithDisableDefaultDate(true),
}))
engine.GET("/", func(_ context.Context, c *app.RequestContext) {
c.String(200, "test")
})
r := ut.PerformRequest(engine, "GET", "/", nil)
assert.DeepEqual(t, "", r.Header().Get("Date"))
}

func TestWithDisableDefaultContentType(t *testing.T) {
h := New(
WithHostPorts("localhost:8324"),
WithDisableDefaultContentType(true),
)
h.GET("/", func(_ context.Context, c *app.RequestContext) {})
go h.Spin()
time.Sleep(100 * time.Millisecond)
hc := http.Client{Timeout: time.Second}
r, _ := hc.Get("http://127.0.0.1:8324") //nolint:errcheck
assert.DeepEqual(t, "", r.Header.Get("Content-Type"))
_ = h.Shutdown(context.TODO()) //nolint:errcheck
}

0 comments on commit 40ce982

Please sign in to comment.