diff --git a/api_test.go b/api_test.go index 57d7a6a..b3124bc 100644 --- a/api_test.go +++ b/api_test.go @@ -104,6 +104,17 @@ type HasEmbeddable struct { Embeddable `inj:""` } +func (c HasEmbeddable) expectedDeps() []GraphNodeDependency { + + return []GraphNodeDependency{ + GraphNodeDependency{ + Name: identifier(reflect.TypeOf(&c.Embeddable)), + Path: ".Embeddable", + Type: reflect.TypeOf(c.Embeddable), + }, + } +} + // Channel instance var ichannel = make(ChanType) diff --git a/graph_node_dependency_test.go b/graph_node_dependency_test.go index 3c1204e..67598eb 100644 --- a/graph_node_dependency_test.go +++ b/graph_node_dependency_test.go @@ -38,6 +38,28 @@ func Test_FindDependencies(t *testing.T) { } } +// findDependencies should populate a known number of deps +func Test_FindDependenciesInEmbeddedStructs(t *testing.T) { + + c := HasEmbeddable{} + d := make([]GraphNodeDependency, 0) + s := EmptyStructPath() + + if e := findDependencies(reflect.TypeOf(c), &d, &s); e != nil { + t.Errorf("Unexpected error: %s", e) + } + + eds := c.expectedDeps() + + if g, e := len(d), len(eds); g != e { + t.Errorf("Expected %d deps in c, got %d", e, g) + } + + for i, ed := range eds { + compareGraphNodeDeps(ed, d[i], t) + } +} + // parseStructTag should return expected struct tags func Test_ParseStructTag(t *testing.T) {