From 0e3b29c55167bb35a011c7d61b19d3ac844b3535 Mon Sep 17 00:00:00 2001 From: corebreaker Date: Tue, 18 Jul 2017 23:13:05 +0300 Subject: [PATCH] Gofmt Former-commit-id: a665e3f1253feb0d520c79ea499cba1f205c9c4f --- core/host/proxy_test.go | 112 ++++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/core/host/proxy_test.go b/core/host/proxy_test.go index a3dd584e..8c4b4921 100644 --- a/core/host/proxy_test.go +++ b/core/host/proxy_test.go @@ -2,76 +2,76 @@ package host_test import ( - "net" - "net/url" - "testing" - "time" + "net" + "net/url" + "testing" + "time" - "github.com/kataras/iris" - "github.com/kataras/iris/context" - "github.com/kataras/iris/core/host" - "github.com/kataras/iris/httptest" + "github.com/kataras/iris" + "github.com/kataras/iris/context" + "github.com/kataras/iris/core/host" + "github.com/kataras/iris/httptest" ) func TestProxy(t *testing.T) { - expectedIndex := "ok /" - expectedAbout := "ok /about" - unexpectedRoute := "unexpected" + expectedIndex := "ok /" + expectedAbout := "ok /about" + unexpectedRoute := "unexpected" - // proxySrv := iris.New() - u, err := url.Parse("https://localhost:4444") - if err != nil { - t.Fatalf("%v while parsing url", err) - } + // proxySrv := iris.New() + u, err := url.Parse("https://localhost:4444") + if err != nil { + t.Fatalf("%v while parsing url", err) + } - // p := host.ProxyHandler(u) - // transport := &http.Transport{ - // TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, - // } - // p.Transport = transport - // proxySrv.Downgrade(p.ServeHTTP) - // go proxySrv.Run(iris.Addr(":80"), iris.WithoutBanner, iris.WithoutInterruptHandler) + // p := host.ProxyHandler(u) + // transport := &http.Transport{ + // TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, + // } + // p.Transport = transport + // proxySrv.Downgrade(p.ServeHTTP) + // go proxySrv.Run(iris.Addr(":80"), iris.WithoutBanner, iris.WithoutInterruptHandler) - proxy := host.NewProxy("", u) + proxy := host.NewProxy("", u) - addr := &net.TCPAddr{ - IP: net.IPv4(127, 0, 0, 1), - Port: 0, - } + addr := &net.TCPAddr{ + IP: net.IPv4(127, 0, 0, 1), + Port: 0, + } - listener, err := net.ListenTCP("tcp", addr) - if err != nil { - t.Fatalf("%v while creating listener", err) - } + listener, err := net.ListenTCP("tcp", addr) + if err != nil { + t.Fatalf("%v while creating listener", err) + } - go proxy.Serve(listener) // should be localhost/127.0.0.1:80 but travis throws permission denied. + go proxy.Serve(listener) // should be localhost/127.0.0.1:80 but travis throws permission denied. - t.Log(listener.Addr().String()) - <-time.After(time.Second) - t.Log(listener.Addr().String()) + t.Log(listener.Addr().String()) + <-time.After(time.Second) + t.Log(listener.Addr().String()) - app := iris.New() - app.Get("/", func(ctx context.Context) { - ctx.WriteString(expectedIndex) - }) + app := iris.New() + app.Get("/", func(ctx context.Context) { + ctx.WriteString(expectedIndex) + }) - app.Get("/about", func(ctx context.Context) { - ctx.WriteString(expectedAbout) - }) + app.Get("/about", func(ctx context.Context) { + ctx.WriteString(expectedAbout) + }) - app.OnErrorCode(iris.StatusNotFound, func(ctx context.Context) { - ctx.WriteString(unexpectedRoute) - }) + app.OnErrorCode(iris.StatusNotFound, func(ctx context.Context) { + ctx.WriteString(unexpectedRoute) + }) - l, err := net.Listen("tcp", "localhost:4444") // should be localhost/127.0.0.1:443 but travis throws permission denied. - if err != nil { - t.Fatalf("%v while creating tcp4 listener for new tls local test listener", err) - } - // main server - go app.Run(iris.Listener(httptest.NewLocalTLSListener(l)), iris.WithoutBanner) + l, err := net.Listen("tcp", "localhost:4444") // should be localhost/127.0.0.1:443 but travis throws permission denied. + if err != nil { + t.Fatalf("%v while creating tcp4 listener for new tls local test listener", err) + } + // main server + go app.Run(iris.Listener(httptest.NewLocalTLSListener(l)), iris.WithoutBanner) - e := httptest.NewInsecure(t, httptest.URL("http://"+listener.Addr().String())) - e.GET("/").Expect().Status(iris.StatusOK).Body().Equal(expectedIndex) - e.GET("/about").Expect().Status(iris.StatusOK).Body().Equal(expectedAbout) - e.GET("/notfound").Expect().Status(iris.StatusNotFound).Body().Equal(unexpectedRoute) + e := httptest.NewInsecure(t, httptest.URL("http://"+listener.Addr().String())) + e.GET("/").Expect().Status(iris.StatusOK).Body().Equal(expectedIndex) + e.GET("/about").Expect().Status(iris.StatusOK).Body().Equal(expectedAbout) + e.GET("/notfound").Expect().Status(iris.StatusNotFound).Body().Equal(unexpectedRoute) }