style: format code

This commit is contained in:
Kevin Franklin Kim 2021-11-15 15:42:36 +01:00
parent 51b33b1006
commit 49b59ea987
5 changed files with 18 additions and 19 deletions

View File

@ -33,7 +33,6 @@ func main() {
webserverPath := config.DefaultWebserverPath(c) webserverPath := config.DefaultWebserverPath(c)
backendURL := config.DefaultBackendURL(c) backendURL := config.DefaultBackendURL(c)
// create proxy // create proxy
proxy, _ := proxy.NewProxy( proxy, _ := proxy.NewProxy(
context.Background(), context.Background(),

View File

@ -3,9 +3,9 @@ package log
import "go.uber.org/zap" import "go.uber.org/zap"
const ( const (
ServiceRoutineKey = "service_routine" ServiceRoutineKey = "service_routine"
CacheIdKey = "cache_id" CacheIdKey = "cache_id"
URLKey = "url" URLKey = "url"
NumberOfWaitingClientsKey = "num_waiting_clients" NumberOfWaitingClientsKey = "num_waiting_clients"
) )

View File

@ -3,13 +3,14 @@ package proxy
import ( import (
"crypto/md5" "crypto/md5"
"encoding/hex" "encoding/hex"
"github.com/foomo/contentfulproxy/packages/go/log"
"go.uber.org/zap"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"sort" "sort"
"strings" "strings"
"sync" "sync"
"github.com/foomo/contentfulproxy/packages/go/log"
"go.uber.org/zap"
) )
type cacheID string type cacheID string

View File

@ -3,9 +3,10 @@ package proxy
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"github.com/foomo/contentfulproxy/packages/go/log"
"net/http" "net/http"
"github.com/foomo/contentfulproxy/packages/go/log"
"go.uber.org/zap" "go.uber.org/zap"
) )

View File

@ -2,21 +2,22 @@ package proxy
import ( import (
"context" "context"
"github.com/stretchr/testify/assert"
"go.uber.org/zap"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"sync" "sync"
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/assert"
"go.uber.org/zap"
) )
const ( const (
responseFoo = `i am a foo response` responseFoo = `i am a foo response`
responseBar = `i am bar response` responseBar = `i am bar response`
responseUpdate = `update` responseUpdate = `update`
responseFlush = `update` responseFlush = `update`
) )
type getStats func(path string) int 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) { func getTestServer(t *testing.T) (gs func(path string) int, ws func(path string) int, s *httptest.Server) {
l, _ := zap.NewProduction() l, _ := zap.NewProduction()
gs, backendHandler := GetBackend(t) gs, backendHandler := GetBackend(t)
@ -93,8 +93,8 @@ func getTestServer(t *testing.T) (gs func(path string) int, ws func(path string)
p, _ := NewProxy( p, _ := NewProxy(
context.Background(), context.Background(),
l, l,
func() string {return backendServer.URL}, func() string { return backendServer.URL },
func() string {return ""}, func() string { return "" },
func() []string { func() []string {
return []string{ return []string{
webHookServer.URL + "/test1", 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) s = httptest.NewServer(p)
t.Log("we have a proxy in front of it running on", s.URL) t.Log("we have a proxy in front of it running on", s.URL)
return gs, ws, s return gs, ws, s
} }
func TestProxy(t *testing.T) { func TestProxy(t *testing.T) {
@ -132,10 +131,9 @@ func TestProxy(t *testing.T) {
} }
assert.Equal(t, 1, gs("/foo")) assert.Equal(t, 1, gs("/foo"))
// check the current status // check the current status
//response, err := http.Get(server.URL + "/info") // response, err := http.Get(server.URL + "/info")
//assert.NoError(t, err) // assert.NoError(t, err)
// //
_, _ = http.Get(server.URL + "/update") _, _ = http.Get(server.URL + "/update")