Skip to content

Commit

Permalink
fix: use high port in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
natesales committed Aug 16, 2023
1 parent 1eb6440 commit b0557dd
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions transport/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,24 @@ func TestTransportHTTPInvalidResolver(t *testing.T) {
}

func TestTransportHTTPServerError(t *testing.T) {
listen := ":53807"
go func() {
http.ListenAndServe(":8084", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
http.ListenAndServe(listen, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Server Error", http.StatusInternalServerError)
}))
}()

tp := httpTransport()
tp.Server = "http://localhost:8084"
tp.Server = "http://localhost" + listen
_, err := tp.Exchange(validQuery())
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "got status code 500")
}

func TestTransportHTTPIDMismatch(t *testing.T) {
listen := ":53808"
go func() {
http.ListenAndServe(":8085", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
http.ListenAndServe(listen, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
msg := dns.Msg{}
msg.Id = 1
buf, err := msg.Pack()
Expand All @@ -67,7 +69,7 @@ func TestTransportHTTPIDMismatch(t *testing.T) {
}()

tp := httpTransport()
tp.Server = "http://localhost:8085"
tp.Server = "http://localhost" + listen
query := validQuery()
reply, err := tp.Exchange(query)
assert.Nil(t, err)
Expand Down

0 comments on commit b0557dd

Please sign in to comment.