Add APISetOptions test for coverage

This commit is contained in:
Samir Patel 2021-10-29 19:04:21 -05:00
parent 21969b1637
commit d828d73eae
3 changed files with 12 additions and 8 deletions

7
api.go
View file

@ -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
}

View file

@ -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

View file

@ -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 {