mirror of https://github.com/databricks/cli.git
This commit is contained in:
parent
4438d1b37c
commit
42d82ede6e
|
@ -115,7 +115,7 @@ func safeToProperty(golangType reflect.Type, seenTypes map[reflect.Type]struct{}
|
||||||
|
|
||||||
// Adds the member fields of golangType to the passed slice. Needed because
|
// Adds the member fields of golangType to the passed slice. Needed because
|
||||||
// golangType can contain embedded fields (aka anonymous)
|
// golangType can contain embedded fields (aka anonymous)
|
||||||
//
|
//
|
||||||
// The function traverses the embedded fields in a breadth first manner
|
// The function traverses the embedded fields in a breadth first manner
|
||||||
//
|
//
|
||||||
// params:
|
// params:
|
||||||
|
@ -151,10 +151,10 @@ func addStructFields(fields []reflect.StructField, golangType reflect.Type) []re
|
||||||
|
|
||||||
// params:
|
// params:
|
||||||
// golangType: golang type for which json schema properties to generate
|
// golangType: golang type for which json schema properties to generate
|
||||||
// seenTypes : set of golang types already seen in path during recursion.
|
// seenTypes : set of golang types already seen in path during recursion.
|
||||||
// Used to identify cycles.
|
// Used to identify cycles.
|
||||||
// debugTrace: linked list of golang types encounted. In case of errors this
|
// debugTrace: linked list of golang types encounted. In case of errors this
|
||||||
// helps log where the error originated from
|
// helps log where the error originated from
|
||||||
func toProperty(golangType reflect.Type, seenTypes map[reflect.Type]struct{}, debugTrace *list.List) (*Property, error) {
|
func toProperty(golangType reflect.Type, seenTypes map[reflect.Type]struct{}, debugTrace *list.List) (*Property, error) {
|
||||||
// *Struct and Struct generate identical json schemas
|
// *Struct and Struct generate identical json schemas
|
||||||
// TODO: add test case for pointer
|
// TODO: add test case for pointer
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/databricks/bricks/bundle/config"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -339,20 +338,20 @@ func TestEmbeddedStructSchema(t *testing.T) {
|
||||||
assert.Equal(t, expected, string(jsonSchema))
|
assert.Equal(t, expected, string(jsonSchema))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only for testing bundle, will be removed
|
// // Only for testing bundle, will be removed
|
||||||
func TestBundleSchema(t *testing.T) {
|
// func TestBundleSchema(t *testing.T) {
|
||||||
elem := config.Root{}
|
// elem := config.Root{}
|
||||||
|
|
||||||
schema, err := NewSchema(reflect.TypeOf(elem))
|
// schema, err := NewSchema(reflect.TypeOf(elem))
|
||||||
assert.NoError(t, err)
|
// assert.NoError(t, err)
|
||||||
|
|
||||||
jsonSchema, err := json.MarshalIndent(schema, " ", " ")
|
// jsonSchema, err := json.MarshalIndent(schema, " ", " ")
|
||||||
assert.NoError(t, err)
|
// assert.NoError(t, err)
|
||||||
|
|
||||||
expected :=
|
// expected :=
|
||||||
``
|
// ``
|
||||||
|
|
||||||
t.Log("[DEBUG] actual: ", string(jsonSchema))
|
// t.Log("[DEBUG] actual: ", string(jsonSchema))
|
||||||
t.Log("[DEBUG] expected: ", expected)
|
// t.Log("[DEBUG] expected: ", expected)
|
||||||
assert.Equal(t, expected, string(jsonSchema))
|
// assert.Equal(t, expected, string(jsonSchema))
|
||||||
}
|
// }
|
||||||
|
|
Loading…
Reference in New Issue