From 49b59ea987fd5596d87b8ee6d705a2d14bc5b8a8 Mon Sep 17 00:00:00 2001 From: Kevin Franklin Kim Date: Mon, 15 Nov 2021 15:42:36 +0100 Subject: [PATCH] style: format code --- cmd/contentfulproxy/main.go | 1 - packages/go/log/log.go | 6 +++--- proxy/cache.go | 5 +++-- proxy/proxy.go | 3 ++- proxy/proxy_test.go | 22 ++++++++++------------ 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/cmd/contentfulproxy/main.go b/cmd/contentfulproxy/main.go index 5f69090..d3cd72a 100644 --- a/cmd/contentfulproxy/main.go +++ b/cmd/contentfulproxy/main.go @@ -33,7 +33,6 @@ func main() { webserverPath := config.DefaultWebserverPath(c) backendURL := config.DefaultBackendURL(c) - // create proxy proxy, _ := proxy.NewProxy( context.Background(), diff --git a/packages/go/log/log.go b/packages/go/log/log.go index b9e9030..f55c8c2 100644 --- a/packages/go/log/log.go +++ b/packages/go/log/log.go @@ -3,9 +3,9 @@ package log import "go.uber.org/zap" const ( - ServiceRoutineKey = "service_routine" - CacheIdKey = "cache_id" - URLKey = "url" + ServiceRoutineKey = "service_routine" + CacheIdKey = "cache_id" + URLKey = "url" NumberOfWaitingClientsKey = "num_waiting_clients" ) diff --git a/proxy/cache.go b/proxy/cache.go index 27489d7..8fe5647 100644 --- a/proxy/cache.go +++ b/proxy/cache.go @@ -3,13 +3,14 @@ package proxy import ( "crypto/md5" "encoding/hex" - "github.com/foomo/contentfulproxy/packages/go/log" - "go.uber.org/zap" "io/ioutil" "net/http" "sort" "strings" "sync" + + "github.com/foomo/contentfulproxy/packages/go/log" + "go.uber.org/zap" ) type cacheID string diff --git a/proxy/proxy.go b/proxy/proxy.go index ee4514f..534bc2c 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -3,9 +3,10 @@ package proxy import ( "context" "encoding/json" - "github.com/foomo/contentfulproxy/packages/go/log" "net/http" + + "github.com/foomo/contentfulproxy/packages/go/log" "go.uber.org/zap" ) diff --git a/proxy/proxy_test.go b/proxy/proxy_test.go index f64b659..113f8de 100644 --- a/proxy/proxy_test.go +++ b/proxy/proxy_test.go @@ -2,21 +2,22 @@ package proxy import ( "context" - "github.com/stretchr/testify/assert" - "go.uber.org/zap" "io/ioutil" "net/http" "net/http/httptest" "sync" "testing" "time" + + "github.com/stretchr/testify/assert" + "go.uber.org/zap" ) const ( - responseFoo = `i am a foo response` - responseBar = `i am bar response` + responseFoo = `i am a foo response` + responseBar = `i am bar response` responseUpdate = `update` - responseFlush = `update` + responseFlush = `update` ) type getStats func(path string) int @@ -82,7 +83,6 @@ func GetWebHook(t *testing.T) (getStats, http.HandlerFunc) { } func getTestServer(t *testing.T) (gs func(path string) int, ws func(path string) int, s *httptest.Server) { - l, _ := zap.NewProduction() gs, backendHandler := GetBackend(t) @@ -93,8 +93,8 @@ func getTestServer(t *testing.T) (gs func(path string) int, ws func(path string) p, _ := NewProxy( context.Background(), l, - func() string {return backendServer.URL}, - func() string {return ""}, + func() string { return backendServer.URL }, + func() string { return "" }, func() []string { return []string{ webHookServer.URL + "/test1", @@ -105,7 +105,6 @@ func getTestServer(t *testing.T) (gs func(path string) int, ws func(path string) s = httptest.NewServer(p) t.Log("we have a proxy in front of it running on", s.URL) return gs, ws, s - } func TestProxy(t *testing.T) { @@ -132,10 +131,9 @@ func TestProxy(t *testing.T) { } assert.Equal(t, 1, gs("/foo")) - // check the current status - //response, err := http.Get(server.URL + "/info") - //assert.NoError(t, err) + // response, err := http.Get(server.URL + "/info") + // assert.NoError(t, err) // _, _ = http.Get(server.URL + "/update")