Merge pull request #1524 from alanbernstein/fix-null-schema

Represent zero indexes in /schema response as [] instead of null
This commit is contained in:
Alan Bernstein 2021-03-11 13:23:19 -06:00 committed by GitHub
commit 7df5375572
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -906,13 +906,13 @@ func (h *Holder) limitedSchema() ([]*IndexInfo, error) {
}
func (h *Holder) schema(ctx context.Context, includeViews bool) ([]*IndexInfo, error) {
var a []*IndexInfo
schema, err := h.schemator.Schema(ctx)
if err != nil {
return nil, errors.Wrapf(err, "getting schema via schemator")
}
a := make([]*IndexInfo, 0, len(schema))
for _, index := range schema {
cim, err := decodeCreateIndexMessage(h.serializer, index.Data)
if err != nil {

View file

@ -106,7 +106,7 @@ func TestHandler_Endpoints(t *testing.T) {
t.Fatalf("unexpected status code: %d", w.Code)
}
body := w.Body.String()
if body != "{\"indexes\":null}\n" {
if body != "{\"indexes\":[]}\n" {
t.Fatalf("unexpected empty schema: '%v'", body)
}
@ -119,7 +119,7 @@ func TestHandler_Endpoints(t *testing.T) {
t.Fatalf("unexpected status code: %d", w.Code)
}
body := w.Body.String()
if body != "{\"indexes\":null}\n" {
if body != "{\"indexes\":[]}\n" {
t.Fatalf("unexpected empty schema: '%v'", body)
}