Open platform to collect and prioritize feedback
restoring file
goenningb625ab5f5b90
diff --git a/handlers/handlers_helper_test.go b/handlers/handlers_helper_test.gonew file mode 100644index 000000000..d377f5de8--- /dev/null+++ b/handlers/handlers_helper_test.go@@ -0,0 +1,43 @@+package handlers_test++import (+ "encoding/json"+ "net/http"+ "net/http/httptest"++ "github.com/WeCanHearYou/wchy/context"+ "github.com/WeCanHearYou/wchy/models"+ "github.com/WeCanHearYou/wchy/router"+ "github.com/WeCanHearYou/wchy/services"+ "github.com/jmoiron/jsonq"+)++func makeRequest(method, url string) (int, *jsonq.JsonQuery) {+ ctx := context.WchyContext{+ Health: &services.InMemoryHealthCheckService{Status: false},+ Tenant: &services.InMemoryTenantService{Tenants: []*models.Tenant{+ &models.Tenant{ID: 1, Name: "Orange Inc.", Domain: "orange"},+ &models.Tenant{ID: 2, Name: "The Triathlon Shop", Domain: "trishop"},+ }},+ Settings: context.WchySettings{+ BuildTime: "today",+ },+ }+ router := router.GetMainEngine(ctx)++ request, _ := http.NewRequest(method, url, nil)+ response := httptest.NewRecorder()+ router.ServeHTTP(response, request)++ status := response.Result().StatusCode++ if status == 200 {+ var data interface{}+ decoder := json.NewDecoder(response.Body)+ decoder.Decode(&data)+ query := jsonq.NewQuery(data)+ return status, query+ }++ return status, nil+}