Skip to content
This repository was archived by the owner on Aug 17, 2018. It is now read-only.

Commit dd5b1b4

Browse files
committed
Coverage
1 parent 163755b commit dd5b1b4

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

siris_test.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/go-siris/siris/context"
2626
"github.com/go-siris/siris/core/errors"
2727
"github.com/go-siris/siris/core/host"
28+
"github.com/go-siris/siris/core/nettools"
2829
"github.com/go-siris/siris/core/router"
2930
"github.com/go-siris/siris/view"
3031
)
@@ -48,6 +49,7 @@ func TestSiris(t *testing.T) {
4849
initial()
4950

5051
app := Default()
52+
app.Configure(WithJSONInteratorReplacement, EnableReuseport, EnableQUICSupport, WithTimeFormat(time.RFC3339), WithCharset("UTF-8"), WithRemoteAddrHeader("X-Real-Ip"), WithoutRemoteAddrHeader("X-No-Real-Ip"), WithOtherValue("AppName", "SIRIS"))
5153
app.AttachView(view.HTML("./", ".html").Binary(get_files, get_names))
5254

5355
app.OnErrorCode(StatusPaymentRequired, func(ctx context.Context) {
@@ -69,7 +71,7 @@ func TestSiris(t *testing.T) {
6971
})
7072

7173
app.Favicon(staticDir)
72-
app.Get("/view", func(ctx context.Context) {
74+
app.Get("/view", context.LimitRequestBodySize(1234567890), func(ctx context.Context) {
7375
ctx.View("view/parent.html")
7476
})
7577
app.Get("/", func(ctx context.Context) {
@@ -237,6 +239,11 @@ func TestSiris(t *testing.T) {
237239
ctx.StatusCode(StatusPaymentRequired)
238240
})
239241

242+
app.Get("/get-gzip", func(ctx context.Context) {
243+
ctx.Gzip(ctx.ClientSupportsGzip())
244+
ctx.Text("Gzip")
245+
})
246+
240247
go func() {
241248
ch := make(chan os.Signal, 1)
242249
signal.Notify(ch,
@@ -280,6 +287,13 @@ func TestSiris(t *testing.T) {
280287
go app.Run(TLS("go-siris.com:9443", sslCert, sslKey), WithoutBanner, WithoutInterruptHandler)
281288
}
282289

290+
unicl, err := nettools.UNIX("/tmp/srv.sock", 0777) // see its code to see how you can manually create a new file listener, it's easy.
291+
if err != nil {
292+
panic(err)
293+
}
294+
295+
go app.Run(Listener(unicl))
296+
283297
loggerP.Write([]byte("Logger: Servers started"))
284298

285299
time.Sleep(time.Duration(5 * time.Second))
@@ -315,8 +329,10 @@ func configureHosts(su *host.Supervisor) {
315329
su.RegisterOnErrorHook(func(err error) {
316330
println("error:" + err.Error())
317331
})
318-
su.RegisterOnServeHook(func(_ host.TaskHost) {
332+
su.RegisterOnServeHook(func(th host.TaskHost) {
319333
println("Server Started")
334+
println(th.HostURL())
335+
println(th.Hostname())
320336
})
321337
// su.RegisterOnError
322338
// su.RegisterOnServe
@@ -502,4 +518,5 @@ func testClient(e *httpexpect.Expect) {
502518
e.GET("/favicon.ico").Expect().Status(StatusOK)
503519

504520
e.GET("/get-payment").Expect().Status(StatusPaymentRequired)
521+
e.GET("/get-gzip").Expect().Status(StatusOK)
505522
}

0 commit comments

Comments
 (0)