Skip to content

Commit

Permalink
Improved embedded struct test
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul M Fox committed Sep 10, 2015
1 parent 5d2cb10 commit 4837b88
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
11 changes: 11 additions & 0 deletions api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
22 changes: 22 additions & 0 deletions graph_node_dependency_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down

0 comments on commit 4837b88

Please sign in to comment.