Files

32 lines
951 B
Go
Raw Permalink Normal View History

package httpapi
import (
"net/http"
"net/http/httptest"
"testing"
)
func TestQueryTruthyWithoutActivePlan(t *testing.T) {
t.Parallel()
req := httptest.NewRequest(http.MethodGet, "/api/admin/companies?without_active_plan=1", nil)
if !QueryTruthy(req, "without_active_plan") {
t.Fatal("expected without_active_plan=1 to be truthy")
}
req = httptest.NewRequest(http.MethodGet, "/api/admin/companies", nil)
if QueryTruthy(req, "without_active_plan") {
t.Fatal("expected missing flag to be false")
}
}
func TestQueryTruthyWithoutAPIKeys(t *testing.T) {
t.Parallel()
req := httptest.NewRequest(http.MethodGet, "/api/admin/companies?without_api_keys=1", nil)
if !QueryTruthy(req, "without_api_keys") {
t.Fatal("expected without_api_keys=1 to be truthy")
}
req = httptest.NewRequest(http.MethodGet, "/api/admin/companies", nil)
if QueryTruthy(req, "without_api_keys") {
t.Fatal("expected missing without_api_keys to be false")
}
}