File tree 2 files changed +25
-6
lines changed
2 files changed +25
-6
lines changed Original file line number Diff line number Diff line change @@ -88,10 +88,11 @@ type controller struct {
88
88
// NewController creates a new reporter.
89
89
func NewController (log * logger.Logger ) Controller {
90
90
return & controller {
91
- status : Healthy ,
92
- reporters : make (map [string ]* reporter ),
93
- appReporters : make (map [string ]* reporter ),
94
- log : log ,
91
+ status : Healthy ,
92
+ reporters : make (map [string ]* reporter ),
93
+ localReporters : make (map [string ]* reporter ),
94
+ appReporters : make (map [string ]* reporter ),
95
+ log : log ,
95
96
}
96
97
}
97
98
@@ -154,12 +155,12 @@ func (r *controller) RegisterLocalComponent(componentIdentifier string) Reporter
154
155
return rep
155
156
}
156
157
157
- // Register registers new component for status updates.
158
+ // RegisterComponent registers new component for status updates.
158
159
func (r * controller ) RegisterComponent (componentIdentifier string ) Reporter {
159
160
return r .RegisterComponentWithPersistance (componentIdentifier , false )
160
161
}
161
162
162
- // Register registers new component for status updates.
163
+ // RegisterComponentWithPersistance registers new component for status updates.
163
164
func (r * controller ) RegisterComponentWithPersistance (componentIdentifier string , persistent bool ) Reporter {
164
165
id := componentIdentifier + "-" + uuid .New ().String ()[:8 ]
165
166
rep := & reporter {
Original file line number Diff line number Diff line change @@ -14,6 +14,24 @@ import (
14
14
"github.com/elastic/elastic-agent/pkg/core/logger"
15
15
)
16
16
17
+ func TestNewController_ensure_all_is_initialzed (t * testing.T ) {
18
+ l , _ := logger .New ("" , false )
19
+
20
+ newController := NewController (l )
21
+
22
+ c , ok := newController .(* controller )
23
+ if ! ok {
24
+ t .Fatalf ("expected c %T, not c %T" , controller {}, newController )
25
+ }
26
+
27
+ c .reporters ["ignore" ] = & reporter {}
28
+ c .localReporters ["ignore" ] = & reporter {}
29
+ c .appReporters ["ignore" ] = & reporter {}
30
+ if c .log == nil {
31
+ t .Error ("logger shouldn't be nil, it was not correctly assigned" )
32
+ }
33
+ }
34
+
17
35
func TestReporter (t * testing.T ) {
18
36
l , _ := logger .New ("" , false )
19
37
t .Run ("healthy by default" , func (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments