diff --git a/.gitignore b/.gitignore index 493893d9..ac8a8d4d 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ cloudflared-x86-64* .DS_Store *-session.log ssh_server_tests/.env +.cover diff --git a/Makefile b/Makefile index 46d83fae..a27f11e6 100644 --- a/Makefile +++ b/Makefile @@ -88,7 +88,13 @@ container: .PHONY: test test: vet +ifndef CI go test -v -mod=vendor -race $(VERSION_FLAGS) ./... +else + @mkdir -p .cover + go test -v -mod=vendor -race $(VERSION_FLAGS) -coverprofile=".cover/c.out" ./... + go tool cover -html ".cover/c.out" -o .cover/all.html +endif .PHONY: test-ssh-server test-ssh-server: diff --git a/hello/hello_test.go b/hello/hello_test.go index d88f478a..44551104 100644 --- a/hello/hello_test.go +++ b/hello/hello_test.go @@ -27,7 +27,7 @@ func TestCreateTLSListenerOnlyHostSuccess(t *testing.T) { } func TestCreateTLSListenerOnlyPortSuccess(t *testing.T) { - listener, err := CreateTLSListener(":8888") + listener, err := CreateTLSListener("localhost:8888") if err != nil { t.Fatal(err) } diff --git a/socks/connection_handler_test.go b/socks/connection_handler_test.go index 40bc9d87..9370de93 100644 --- a/socks/connection_handler_test.go +++ b/socks/connection_handler_test.go @@ -42,7 +42,7 @@ func startTestServer(t *testing.T, httpHandler func(w http.ResponseWriter, r *ht // create a socks server requestHandler := NewRequestHandler(NewNetDialer()) socksServer := NewConnectionHandler(requestHandler) - listener, err := net.Listen("tcp", ":8086") + listener, err := net.Listen("tcp", "localhost:8086") assert.NoError(t, err) go func() { @@ -58,7 +58,7 @@ func startTestServer(t *testing.T, httpHandler func(w http.ResponseWriter, r *ht mux.HandleFunc("/", httpHandler) // start the servers - go http.ListenAndServe(":8085", mux) + go http.ListenAndServe("localhost:8085", mux) } func respondWithJSON(w http.ResponseWriter, v interface{}, status int) {