-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix TestHttpProbe/returns_the_status_code_if_the_request_is_successful #55
Conversation
Thank you! I would prefer to merge a proper solution instead this workaround. The problem here is the function Lines 66 to 67 in 520cd9e
Please check this solution. I think it should work: https://stackoverflow.com/a/53332769 |
thanks for suggestion it work |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. Only a couple of formatting changes are we are ready to merge. :)
pkg/protocols_test.go
Outdated
server := &http.Server{Addr: hostPort} | ||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | ||
mux := http.NewServeMux() | ||
server := &http.Server{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, use one line to define server
.
pkg/protocols_test.go
Outdated
Addr: hostPort, | ||
Handler:mux, | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, remove the empty lines to keep the formatting consistent.
pkg/protocols_test.go
Outdated
go func() { | ||
err := server.ListenAndServe() | ||
if err != nil && err != http.ErrServerClosed { | ||
if err := server.Serve(l); err != nil && err != http.ErrServerClosed { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use two different lines. Also to keep the formatting consistent with the codebase.
pkg/protocols_test.go
Outdated
@@ -59,19 +59,30 @@ func TestHttpProbe(t *testing.T) { | |||
// Creates an HTTP server for testing. | |||
func newTestHTTPServer(t *testing.T) *http.Server { | |||
hostPort := net.JoinHostPort("127.0.0.1", "8080") | |||
server := &http.Server{Addr: hostPort} | |||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | |||
mux := http.NewServeMux() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need a mux for this simple scenario. The line 63 should be enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay got it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you :)
Fixes #52.