Beispiel #1
0
func TestEndpoint(t *testing.T) {

	ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
	defer ts.Close()

	conf := rapi.NewConfig()
	conf.Backend.Address = strings.TrimPrefix(ts.URL, "http://")

	api := rapi.New(conf)
	require.NotNil(t, api)

	ep := rapi.NewEndpoint(api, "GET", "/foo")
	assert.NotNil(t, ep)

	req, err := http.NewRequest("GET", "/foo", nil)
	require.Nil(t, err)
	require.NotNil(t, req)

	resp := httptest.NewRecorder()
	require.NotNil(t, resp)

	ep.ServeHTTP(resp, req)
}
Beispiel #2
0
func TestEmptyConfig(t *testing.T) {
	rapi.NewConfig()
}
Beispiel #3
0
func TestCreateApi(t *testing.T) {
	config := rapi.NewConfig()
	rapi.New(config)
}