@@ -116,7 +116,7 @@ func TestDotGraph(t *testing.T) {
116
116
assertCtorsEqual (t , expected , dg .Ctors )
117
117
})
118
118
119
- t .Run ("create graph with multple constructors" , func (t * testing.T ) {
119
+ t .Run ("create graph with multiple constructors" , func (t * testing.T ) {
120
120
expected := []* dot.Ctor {
121
121
{
122
122
Params : []* dot.Param {p1 },
@@ -141,6 +141,62 @@ func TestDotGraph(t *testing.T) {
141
141
assertCtorsEqual (t , expected , dg .Ctors )
142
142
})
143
143
144
+ t .Run ("create graph with scope" , func (t * testing.T ) {
145
+ expected := []* dot.Ctor {
146
+ {
147
+ Params : []* dot.Param {p1 },
148
+ Results : []* dot.Result {r2 },
149
+ },
150
+ {
151
+ Params : []* dot.Param {p1 },
152
+ Results : []* dot.Result {r3 },
153
+ },
154
+ {
155
+ Params : []* dot.Param {p2 },
156
+ Results : []* dot.Result {r4 },
157
+ },
158
+ }
159
+
160
+ c := digtest .New (t )
161
+ c .Provide (func (A t1 ) t2 { return t2 {} })
162
+
163
+ s := c .Scope ("test" )
164
+ s .Provide (func (A t1 ) t3 { return t3 {} })
165
+ s .Provide (func (A t2 ) t4 { return t4 {} })
166
+
167
+ dg := c .CreateGraph ()
168
+ assertCtorsEqual (t , expected , dg .Ctors )
169
+ })
170
+
171
+ t .Run ("create graph with child scope" , func (t * testing.T ) {
172
+ expected := []* dot.Ctor {
173
+ {
174
+ Params : []* dot.Param {p1 },
175
+ Results : []* dot.Result {r2 },
176
+ },
177
+ {
178
+ Params : []* dot.Param {p1 },
179
+ Results : []* dot.Result {r3 },
180
+ },
181
+ {
182
+ Params : []* dot.Param {p2 },
183
+ Results : []* dot.Result {r4 },
184
+ },
185
+ }
186
+
187
+ c := digtest .New (t )
188
+ c .Provide (func (A t1 ) t2 { return t2 {} })
189
+
190
+ s := c .Scope ("parent_scope" )
191
+ s .Provide (func (A t1 ) t3 { return t3 {} })
192
+
193
+ cs := s .Scope ("child_scope" )
194
+ cs .Provide (func (A t2 ) t4 { return t4 {} })
195
+
196
+ dg := c .CreateGraph ()
197
+ assertCtorsEqual (t , expected , dg .Ctors )
198
+ })
199
+
144
200
t .Run ("constructor with multiple params and results" , func (t * testing.T ) {
145
201
expected := []* dot.Ctor {
146
202
{
0 commit comments