From d828d73eaef91e4060f5a9a1dcb6bb8f22bd7fdf Mon Sep 17 00:00:00 2001 From: Samir Patel <48686912+54mir@users.noreply.github.com> Date: Fri, 29 Oct 2021 19:04:21 -0500 Subject: [PATCH] Add APISetOptions test for coverage --- api.go | 7 ++----- api_test.go | 9 ++++++++- server/handler_test.go | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/api.go b/api.go index 3d65dba70..3d4961626 100644 --- a/api.go +++ b/api.go @@ -128,12 +128,9 @@ func NewAPI(opts ...apiOption) (*API, error) { } // Setter for API options. -func (api *API) SetAPIOpetions(opts ...apiOption) error { +func (api *API) SetAPIOptions(opts ...apiOption) error { for _, opt := range opts { - err := opt(api) - if err != nil { - return errors.Wrap(err, "applying option") - } + opt(api) } return nil } diff --git a/api_test.go b/api_test.go index 50a59a03e..9aafae717 100644 --- a/api_test.go +++ b/api_test.go @@ -26,7 +26,7 @@ import ( "testing" "time" - "github.com/molecula/featurebase/v2" + pilosa "github.com/molecula/featurebase/v2" "github.com/molecula/featurebase/v2/boltdb" "github.com/molecula/featurebase/v2/http" "github.com/molecula/featurebase/v2/server" @@ -846,6 +846,13 @@ func TestAPI_IDAlloc(t *testing.T) { }) } +func TestAPI_SetAPIOptions(t *testing.T) { + cluster := test.MustRunCluster(t, 1) + defer cluster.Close() + cmd := cluster.GetNode(0) + cmd.API.SetAPIOptions(pilosa.OptAPISchemaDetailsOn(false)) +} + type mutexCheckIndex struct { index *pilosa.Index indexName string diff --git a/server/handler_test.go b/server/handler_test.go index e7212892d..e4c28bece 100644 --- a/server/handler_test.go +++ b/server/handler_test.go @@ -345,8 +345,8 @@ func TestHandler_Endpoints(t *testing.T) { }) t.Run("SchemaDetailsOff", func(t *testing.T) { - cmd.API.SetAPIOpetions(pilosa.OptAPISchemaDetailsOn(false)) - defer cmd.API.SetAPIOpetions(pilosa.OptAPISchemaDetailsOn(true)) + cmd.API.SetAPIOptions(pilosa.OptAPISchemaDetailsOn(false)) + defer cmd.API.SetAPIOptions(pilosa.OptAPISchemaDetailsOn(true)) w := httptest.NewRecorder() h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/schema/details", nil)) if w.Code != gohttp.StatusOK {