mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-10 04:47:53 +00:00
Add some error handling
This commit is contained in:
parent
163492801f
commit
faa831928c
3 changed files with 19 additions and 5 deletions
5
api.go
5
api.go
|
|
@ -130,7 +130,10 @@ func NewAPI(opts ...apiOption) (*API, error) {
|
|||
// Setter for API options.
|
||||
func (api *API) SetAPIOptions(opts ...apiOption) error {
|
||||
for _, opt := range opts {
|
||||
opt(api)
|
||||
err := opt(api)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "setting API option")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -850,7 +850,10 @@ func TestAPI_SchemaDetailsOff(t *testing.T) {
|
|||
cluster := test.MustRunCluster(t, 2)
|
||||
defer cluster.Close()
|
||||
cmd := cluster.GetNode(0)
|
||||
cmd.API.SetAPIOptions(pilosa.OptAPISchemaDetailsOn(false))
|
||||
err := cmd.API.SetAPIOptions(pilosa.OptAPISchemaDetailsOn(false))
|
||||
if err != nil {
|
||||
t.Fatalf("could not toggle schema details to off: %v", err)
|
||||
}
|
||||
schema, err := cmd.API.SchemaDetails(context.Background())
|
||||
if err != nil {
|
||||
t.Fatalf("getting schema: %v", err)
|
||||
|
|
|
|||
|
|
@ -345,8 +345,11 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("SchemaDetailsOff", func(t *testing.T) {
|
||||
cmd.API.SetAPIOptions(pilosa.OptAPISchemaDetailsOn(false))
|
||||
defer cmd.API.SetAPIOptions(pilosa.OptAPISchemaDetailsOn(true))
|
||||
err := cmd.API.SetAPIOptions(pilosa.OptAPISchemaDetailsOn(false))
|
||||
if err != nil {
|
||||
t.Fatalf("setting schema details option")
|
||||
}
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/schema/details", nil))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
|
|
@ -357,8 +360,8 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
if err := json.Unmarshal(w.Body.Bytes(),
|
||||
&bodySchema); err != nil {
|
||||
t.Fatalf("unexpected unmarshalling error: %v", err)
|
||||
}
|
||||
|
||||
}
|
||||
for _, i := range bodySchema.Indexes {
|
||||
for _, f := range i.Fields {
|
||||
if f.Cardinality != nil {
|
||||
|
|
@ -366,6 +369,11 @@ func TestHandler_Endpoints(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
err = cmd.API.SetAPIOptions(pilosa.OptAPISchemaDetailsOn(true))
|
||||
if err != nil {
|
||||
t.Fatalf("could not toggle schema details to on: %v", err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Import", func(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue