mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 09:05:55 +00:00
Add APISetOptions test for coverage
This commit is contained in:
parent
21969b1637
commit
d828d73eae
3 changed files with 12 additions and 8 deletions
7
api.go
7
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue