@@ -21,6 +21,7 @@ import (
21
21
22
22
"go.opentelemetry.io/collector/component"
23
23
"go.opentelemetry.io/collector/exporter/exporterhelper/internal/experr"
24
+ "go.opentelemetry.io/collector/exporter/exporterhelper/internal/hosttest"
24
25
"go.opentelemetry.io/collector/exporter/exporterhelper/internal/storagetest"
25
26
"go.opentelemetry.io/collector/exporter/exportertest"
26
27
"go.opentelemetry.io/collector/extension/extensiontest"
@@ -51,15 +52,6 @@ func (uint64Encoding) Unmarshal(bytes []byte) (uint64, error) {
51
52
return binary .LittleEndian .Uint64 (bytes ), nil
52
53
}
53
54
54
- type mockHost struct {
55
- component.Host
56
- ext map [component.ID ]component.Component
57
- }
58
-
59
- func (nh * mockHost ) GetExtensions () map [component.ID ]component.Component {
60
- return nh .ext
61
- }
62
-
63
55
func newFakeBoundedStorageClient (maxSizeInBytes int ) * fakeBoundedStorageClient {
64
56
return & fakeBoundedStorageClient {
65
57
st : map [string ][]byte {},
@@ -233,9 +225,9 @@ func createAndStartTestPersistentQueue(t *testing.T, sizer sizer[uint64], capaci
233
225
ac := newAsyncQueue (pq , numConsumers , func (ctx context.Context , item uint64 , done Done ) {
234
226
done .OnDone (consumeFunc (ctx , item ))
235
227
})
236
- host := & mockHost { ext : map [component.ID ]component.Component {
228
+ host := hosttest . NewHost ( map [component.ID ]component.Component {
237
229
{}: storagetest .NewMockStorageExtension (nil ),
238
- }}
230
+ })
239
231
require .NoError (t , ac .Start (context .Background (), host ))
240
232
t .Cleanup (func () {
241
233
assert .NoError (t , ac .Shutdown (context .Background ()))
@@ -275,7 +267,7 @@ func createTestPersistentQueueWithCapacityLimiter(tb testing.TB, ext storage.Ext
275
267
encoding : uint64Encoding {},
276
268
set : exportertest .NewNopSettings (exportertest .NopType ),
277
269
}).(* persistentQueue [uint64 ])
278
- require .NoError (tb , pq .Start (context .Background (), & mockHost { ext : map [component.ID ]component.Component {{}: ext }} ))
270
+ require .NoError (tb , pq .Start (context .Background (), hosttest . NewHost ( map [component.ID ]component.Component {{}: ext }) ))
279
271
return pq
280
272
}
281
273
@@ -427,9 +419,9 @@ func TestPersistentBlockingQueue(t *testing.T) {
427
419
consumed .Add (1 )
428
420
done .OnDone (nil )
429
421
})
430
- host := & mockHost { ext : map [component.ID ]component.Component {
422
+ host := hosttest . NewHost ( map [component.ID ]component.Component {
431
423
{}: storagetest .NewMockStorageExtension (nil ),
432
- }}
424
+ })
433
425
require .NoError (t , ac .Start (context .Background (), host ))
434
426
435
427
td := uint64 (10 )
@@ -498,7 +490,7 @@ func TestToStorageClient(t *testing.T) {
498
490
for i := 0 ; i < tt .numStorages ; i ++ {
499
491
extensions [component .MustNewIDWithName ("file_storage" , strconv .Itoa (i ))] = storagetest .NewMockStorageExtension (tt .getClientError )
500
492
}
501
- host := & mockHost { ext : extensions }
493
+ host := hosttest . NewHost ( extensions )
502
494
ownerID := component .MustNewID ("foo_exporter" )
503
495
504
496
// execute
@@ -528,7 +520,7 @@ func TestInvalidStorageExtensionType(t *testing.T) {
528
520
extensions := map [component.ID ]component.Component {
529
521
storageID : extension ,
530
522
}
531
- host := & mockHost { ext : extensions }
523
+ host := hosttest . NewHost ( extensions )
532
524
ownerID := component .MustNewID ("foo_exporter" )
533
525
534
526
// execute
0 commit comments