@@ -46,7 +46,7 @@ func TestRegistry_RegisterComponents_Success(t *testing.T) {
46
46
lib := chasm .NewMockLibrary (ctrl )
47
47
lib .EXPECT ().Name ().Return ("TestLibrary" ).AnyTimes ()
48
48
lib .EXPECT ().Components ().Return ([]* chasm.RegistrableComponent {
49
- chasm.NewRegistrableComponent [* chasm.MockComponent ]("Component1" ),
49
+ chasm .NewRegistrableComponent [* chasm.MockComponent ]("Component1" , lib ),
50
50
})
51
51
52
52
lib .EXPECT ().Tasks ().Return (nil )
@@ -56,7 +56,7 @@ func TestRegistry_RegisterComponents_Success(t *testing.T) {
56
56
57
57
rc1 , ok := r .Component ("TestLibrary.Component1" )
58
58
require .True (t , ok )
59
- require .Equal (t , "Component1" , rc1 .Type ())
59
+ require .Equal (t , "TestLibrary. Component1" , rc1 .Type ())
60
60
61
61
missingRC , ok := r .Component ("TestLibrary.Component2" )
62
62
require .False (t , ok )
@@ -65,7 +65,7 @@ func TestRegistry_RegisterComponents_Success(t *testing.T) {
65
65
cInstance1 := chasm .NewMockComponent (ctrl )
66
66
rc2 , ok := r .ComponentFor (cInstance1 )
67
67
require .True (t , ok )
68
- require .Equal (t , "Component1" , rc2 .Type ())
68
+ require .Equal (t , "TestLibrary. Component1" , rc2 .Type ())
69
69
70
70
cInstance2 := "invalid component instance"
71
71
rc3 , ok := r .ComponentFor (cInstance2 )
@@ -81,16 +81,16 @@ func TestRegistry_RegisterTasks_Success(t *testing.T) {
81
81
lib .EXPECT ().Components ().Return (nil )
82
82
83
83
lib .EXPECT ().Tasks ().Return ([]* chasm.RegistrableTask {
84
- chasm .NewRegistrableTask [* chasm.MockComponent , testTask1 ]("Task1" , chasm.NewMockTaskHandler [* chasm.MockComponent , testTask1 ](ctrl )),
85
- chasm .NewRegistrableTask [testTaskComponentInterface , testTask2 ]("Task2" , chasm.NewMockTaskHandler [testTaskComponentInterface , testTask2 ](ctrl )),
84
+ chasm .NewRegistrableTask [* chasm.MockComponent , testTask1 ]("Task1" , lib , chasm.NewMockTaskHandler [* chasm.MockComponent , testTask1 ](ctrl )),
85
+ chasm .NewRegistrableTask [testTaskComponentInterface , testTask2 ]("Task2" , lib , chasm.NewMockTaskHandler [testTaskComponentInterface , testTask2 ](ctrl )),
86
86
})
87
87
88
88
err := r .Register (lib )
89
89
require .NoError (t , err )
90
90
91
91
rt1 , ok := r .Task ("TestLibrary.Task1" )
92
92
require .True (t , ok )
93
- require .Equal (t , "Task1" , rt1 .Type ())
93
+ require .Equal (t , "TestLibrary. Task1" , rt1 .Type ())
94
94
95
95
missingRT , ok := r .Task ("TestLibrary.TaskMissing" )
96
96
require .False (t , ok )
@@ -99,7 +99,7 @@ func TestRegistry_RegisterTasks_Success(t *testing.T) {
99
99
tInstance1 := testTask2 {}
100
100
rt2 , ok := r .TaskFor (tInstance1 )
101
101
require .True (t , ok )
102
- require .Equal (t , "Task2" , rt2 .Type ())
102
+ require .Equal (t , "TestLibrary. Task2" , rt2 .Type ())
103
103
104
104
tInstance2 := "invalid task instance"
105
105
rt3 , ok := r .TaskFor (tInstance2 )
@@ -135,7 +135,7 @@ func TestRegistry_RegisterComponents_Error(t *testing.T) {
135
135
136
136
t .Run ("component name must not be empty" , func (t * testing.T ) {
137
137
lib .EXPECT ().Components ().Return ([]* chasm.RegistrableComponent {
138
- chasm.NewRegistrableComponent [* chasm.MockComponent ]("" ),
138
+ chasm .NewRegistrableComponent [* chasm.MockComponent ]("" , lib ),
139
139
})
140
140
r := chasm .NewRegistry ()
141
141
err := r .Register (lib )
@@ -145,7 +145,7 @@ func TestRegistry_RegisterComponents_Error(t *testing.T) {
145
145
146
146
t .Run ("component name must follow rules" , func (t * testing.T ) {
147
147
lib .EXPECT ().Components ().Return ([]* chasm.RegistrableComponent {
148
- chasm.NewRegistrableComponent [* chasm.MockComponent ]("bad.component.name" ),
148
+ chasm .NewRegistrableComponent [* chasm.MockComponent ]("bad.component.name" , lib ),
149
149
})
150
150
r := chasm .NewRegistry ()
151
151
err := r .Register (lib )
@@ -155,8 +155,8 @@ func TestRegistry_RegisterComponents_Error(t *testing.T) {
155
155
156
156
t .Run ("component is already registered by name" , func (t * testing.T ) {
157
157
lib .EXPECT ().Components ().Return ([]* chasm.RegistrableComponent {
158
- chasm.NewRegistrableComponent [* chasm.MockComponent ]("Component1" ),
159
- chasm.NewRegistrableComponent [* chasm.MockComponent ]("Component1" ),
158
+ chasm .NewRegistrableComponent [* chasm.MockComponent ]("Component1" , lib ),
159
+ chasm .NewRegistrableComponent [* chasm.MockComponent ]("Component1" , lib ),
160
160
})
161
161
r := chasm .NewRegistry ()
162
162
err := r .Register (lib )
@@ -166,8 +166,8 @@ func TestRegistry_RegisterComponents_Error(t *testing.T) {
166
166
167
167
t .Run ("component is already registered by type" , func (t * testing.T ) {
168
168
lib .EXPECT ().Components ().Return ([]* chasm.RegistrableComponent {
169
- chasm.NewRegistrableComponent [* chasm.MockComponent ]("Component1" ),
170
- chasm.NewRegistrableComponent [* chasm.MockComponent ]("Component2" ),
169
+ chasm .NewRegistrableComponent [* chasm.MockComponent ]("Component1" , lib ),
170
+ chasm .NewRegistrableComponent [* chasm.MockComponent ]("Component2" , lib ),
171
171
})
172
172
r := chasm .NewRegistry ()
173
173
@@ -178,7 +178,7 @@ func TestRegistry_RegisterComponents_Error(t *testing.T) {
178
178
179
179
t .Run ("component must be a struct" , func (t * testing.T ) {
180
180
lib .EXPECT ().Components ().Return ([]* chasm.RegistrableComponent {
181
- chasm.NewRegistrableComponent [chasm.Component ]("Component1" ),
181
+ chasm .NewRegistrableComponent [chasm.Component ]("Component1" , lib ),
182
182
})
183
183
r := chasm .NewRegistry ()
184
184
@@ -198,7 +198,7 @@ func TestRegistry_RegisterTasks_Error(t *testing.T) {
198
198
t .Run ("task name must not be empty" , func (t * testing.T ) {
199
199
r := chasm .NewRegistry ()
200
200
lib .EXPECT ().Tasks ().Return ([]* chasm.RegistrableTask {
201
- chasm .NewRegistrableTask [* chasm.MockComponent , testTask1 ]("" , chasm.NewMockTaskHandler [* chasm.MockComponent , testTask1 ](ctrl )),
201
+ chasm .NewRegistrableTask [* chasm.MockComponent , testTask1 ]("" , lib , chasm.NewMockTaskHandler [* chasm.MockComponent , testTask1 ](ctrl )),
202
202
})
203
203
err := r .Register (lib )
204
204
require .Error (t , err )
@@ -207,7 +207,7 @@ func TestRegistry_RegisterTasks_Error(t *testing.T) {
207
207
208
208
t .Run ("task name must follow rules" , func (t * testing.T ) {
209
209
lib .EXPECT ().Tasks ().Return ([]* chasm.RegistrableTask {
210
- chasm .NewRegistrableTask [* chasm.MockComponent , testTask1 ]("bad.task.name" , chasm.NewMockTaskHandler [* chasm.MockComponent , testTask1 ](ctrl )),
210
+ chasm .NewRegistrableTask [* chasm.MockComponent , testTask1 ]("bad.task.name" , lib , chasm.NewMockTaskHandler [* chasm.MockComponent , testTask1 ](ctrl )),
211
211
})
212
212
r := chasm .NewRegistry ()
213
213
err := r .Register (lib )
@@ -217,8 +217,8 @@ func TestRegistry_RegisterTasks_Error(t *testing.T) {
217
217
218
218
t .Run ("task is already registered by name" , func (t * testing.T ) {
219
219
lib .EXPECT ().Tasks ().Return ([]* chasm.RegistrableTask {
220
- chasm .NewRegistrableTask [* chasm.MockComponent , testTask1 ]("Task1" , chasm.NewMockTaskHandler [* chasm.MockComponent , testTask1 ](ctrl )),
221
- chasm .NewRegistrableTask [* chasm.MockComponent , testTask1 ]("Task1" , chasm.NewMockTaskHandler [* chasm.MockComponent , testTask1 ](ctrl )),
220
+ chasm .NewRegistrableTask [* chasm.MockComponent , testTask1 ]("Task1" , lib , chasm.NewMockTaskHandler [* chasm.MockComponent , testTask1 ](ctrl )),
221
+ chasm .NewRegistrableTask [* chasm.MockComponent , testTask1 ]("Task1" , lib , chasm.NewMockTaskHandler [* chasm.MockComponent , testTask1 ](ctrl )),
222
222
})
223
223
r := chasm .NewRegistry ()
224
224
err := r .Register (lib )
@@ -228,8 +228,8 @@ func TestRegistry_RegisterTasks_Error(t *testing.T) {
228
228
229
229
t .Run ("task is already registered by type" , func (t * testing.T ) {
230
230
lib .EXPECT ().Tasks ().Return ([]* chasm.RegistrableTask {
231
- chasm .NewRegistrableTask [* chasm.MockComponent , testTask1 ]("Task1" , chasm.NewMockTaskHandler [* chasm.MockComponent , testTask1 ](ctrl )),
232
- chasm .NewRegistrableTask [* chasm.MockComponent , testTask1 ]("Task2" , chasm.NewMockTaskHandler [* chasm.MockComponent , testTask1 ](ctrl )),
231
+ chasm .NewRegistrableTask [* chasm.MockComponent , testTask1 ]("Task1" , lib , chasm.NewMockTaskHandler [* chasm.MockComponent , testTask1 ](ctrl )),
232
+ chasm .NewRegistrableTask [* chasm.MockComponent , testTask1 ]("Task2" , lib , chasm.NewMockTaskHandler [* chasm.MockComponent , testTask1 ](ctrl )),
233
233
})
234
234
r := chasm .NewRegistry ()
235
235
err := r .Register (lib )
@@ -240,7 +240,7 @@ func TestRegistry_RegisterTasks_Error(t *testing.T) {
240
240
t .Run ("task component struct must implement Component" , func (t * testing.T ) {
241
241
lib .EXPECT ().Tasks ().Return ([]* chasm.RegistrableTask {
242
242
// MockComponent has only pointer receivers and therefore does not implement Component interface.
243
- chasm .NewRegistrableTask [chasm.MockComponent , testTask1 ]("Task1" , chasm.NewMockTaskHandler [chasm.MockComponent , testTask1 ](ctrl )),
243
+ chasm .NewRegistrableTask [chasm.MockComponent , testTask1 ]("Task1" , lib , chasm.NewMockTaskHandler [chasm.MockComponent , testTask1 ](ctrl )),
244
244
})
245
245
r := chasm .NewRegistry ()
246
246
err := r .Register (lib )
@@ -250,7 +250,7 @@ func TestRegistry_RegisterTasks_Error(t *testing.T) {
250
250
251
251
t .Run ("task must be struct" , func (t * testing.T ) {
252
252
lib .EXPECT ().Tasks ().Return ([]* chasm.RegistrableTask {
253
- chasm .NewRegistrableTask [* chasm.MockComponent , string ]("Task1" , chasm.NewMockTaskHandler [* chasm.MockComponent , string ](ctrl )),
253
+ chasm .NewRegistrableTask [* chasm.MockComponent , string ]("Task1" , lib , chasm.NewMockTaskHandler [* chasm.MockComponent , string ](ctrl )),
254
254
})
255
255
r := chasm .NewRegistry ()
256
256
err := r .Register (lib )
0 commit comments