mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-11-23 20:35:24 +01:00
6e1a6d20ca
Rename util to helpers Bind returns bool instead of error
32 lines
539 B
Go
32 lines
539 B
Go
package helpers
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"github.com/gorilla/mux"
|
|
)
|
|
|
|
func TestGetIntParam(t *testing.T) {
|
|
req, _ := http.NewRequest("GET", "/test/123", nil)
|
|
rr := httptest.NewRecorder()
|
|
|
|
r := mux.NewRouter()
|
|
r.HandleFunc("/test/{test_id}", mockParam)
|
|
r.ServeHTTP(rr, req)
|
|
|
|
if rr.Code != 200 {
|
|
t.Errorf("Response code should be 200 %d", rr.Code)
|
|
}
|
|
}
|
|
|
|
func mockParam(w http.ResponseWriter, r *http.Request) {
|
|
_, err := GetIntParam("test_id", w, r)
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
w.WriteHeader(200)
|
|
}
|