Skip to content

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
mihir20 committed Mar 13, 2024
1 parent d3e3529 commit c94723d
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions testhelper/httptest/httptest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestServer(t *testing.T) {

func TestUnStartedServer(t *testing.T) {
// create a server which is not started
httpUnStartedServer := kithttptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
httpUnStartedServer := kithttptest.NewUnStartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_, _ = w.Write([]byte("Hello, world!"))
}))

Expand All @@ -55,12 +55,8 @@ func TestUnStartedServer(t *testing.T) {
statusCode int
)
require.Never(t, func() bool {
resp, err := http.Get(httpUnStartedServer.URL)
resp, err := http.Get("http://" + httpUnStartedServer.Listener.Addr().String())
defer func() { httputil.CloseResponse(resp) }()
if err == nil {
statusCode = resp.StatusCode
body, err = io.ReadAll(resp.Body)
}
return err == nil
}, 5*time.Second, time.Second, "connected to an un-started server")

Expand Down

0 comments on commit c94723d

Please sign in to comment.