@@ -3,20 +3,24 @@ package writetarget_test
33import (
44 "testing"
55
6+ "github.com/stretchr/testify/mock"
7+ "github.com/stretchr/testify/require"
8+ "go.uber.org/zap/zapcore"
9+
610 "github.com/smartcontractkit/chainlink-common/pkg/logger"
11+ "github.com/smartcontractkit/chainlink-common/pkg/utils/tests"
12+
713 "github.com/smartcontractkit/chainlink-framework/capabilities/writetarget"
814 monitor "github.com/smartcontractkit/chainlink-framework/capabilities/writetarget/beholder/monitor"
915 "github.com/smartcontractkit/chainlink-framework/capabilities/writetarget/mocks"
1016 wt "github.com/smartcontractkit/chainlink-framework/capabilities/writetarget/monitoring/pb/platform"
11- "github.com/test-go/testify/mock"
12-
13- "github.com/stretchr/testify/require"
1417)
1518
1619func TestWriteTargetMonitor (t * testing.T ) {
1720 processor := mocks .NewProductSpecificProcessor (t )
21+ lggr , observed := logger .TestObserved (t , zapcore .DebugLevel )
1822
19- monitor , err := writetarget .NewMonitor (logger . Test ( t ) , []monitor.ProtoProcessor {}, []writetarget.ProductSpecificProcessor {processor }, writetarget .NewMonitorEmitter (logger . Test ( t ) ))
23+ monitor , err := writetarget .NewMonitor (lggr , []monitor.ProtoProcessor {}, []writetarget.ProductSpecificProcessor {processor }, writetarget .NewMonitorEmitter (lggr ))
2024 require .NoError (t , err )
2125
2226 encoded := []byte {}
@@ -30,13 +34,16 @@ func TestWriteTargetMonitor(t *testing.T) {
3034 t .Run ("Uses processor when name equals config" , func (t * testing.T ) {
3135 processor .On ("Name" ).Return ("test" ).Once ()
3236 processor .On ("Process" , t .Context (), msg , mock .Anything ).Return (nil ).Once ()
33- monitor .ProtoEmitter .EmitWithLog (t .Context (), msg )
37+ err := monitor .ProtoEmitter .EmitWithLog (t .Context (), msg )
38+ require .NoError (t , err )
3439 })
3540
36- t .Run ("Errors when config name is not found" , func (t * testing.T ) {
41+ t .Run ("Logs when config name is not found" , func (t * testing.T ) {
3742 processor .On ("Name" ).Return ("other" )
3843 err := monitor .ProtoEmitter .EmitWithLog (t .Context (), msg )
39- require .Error (t , err )
44+ require .NoError (t , err )
45+
46+ tests .RequireLogMessage (t , observed , "no matching processor for MetaCapabilityProcessor=test" )
4047 })
4148
4249 t .Run ("Does not use processor when none is configured" , func (t * testing.T ) {
@@ -47,5 +54,7 @@ func TestWriteTargetMonitor(t *testing.T) {
4754
4855 err := monitor .ProtoEmitter .EmitWithLog (t .Context (), msg )
4956 require .NoError (t , err )
57+
58+ tests .RequireLogMessage (t , observed , "No product specific processor specified; skipping." )
5059 })
5160}
0 commit comments