@@ -10,10 +10,12 @@ import (
1010 "time"
1111
1212 "github.com/stretchr/testify/assert"
13+ "github.com/stretchr/testify/mock"
1314 "github.com/stretchr/testify/require"
1415 "go.opentelemetry.io/otel/attribute"
1516 "go.opentelemetry.io/otel/sdk/metric/metricdata"
1617
18+ "github.com/smartcontractkit/chainlink-common/pkg/config"
1719 "github.com/smartcontractkit/chainlink-common/pkg/contexts"
1820 "github.com/smartcontractkit/chainlink-common/pkg/settings"
1921)
@@ -125,6 +127,31 @@ func ExampleMultiResourcePoolLimiter() {
125127 // <nil>
126128}
127129
130+ func TestMakeResourcePoolLimiter_Update (t * testing.T ) {
131+ t .Parallel ()
132+ ctx := t .Context ()
133+ getter := NewGetter (t )
134+ getter .On ("GetScoped" , mock .Anything , settings .ScopeGlobal , "foo" ).Return ("10" , nil ).Twice ()
135+ f := Factory {Settings : getter }
136+ s := settings .Size (1 )
137+ s .Key = "foo"
138+ rl , err := MakeResourcePoolLimiter (f , s )
139+ require .NoError (t , err )
140+
141+ // validate
142+ a , err := rl .Available (ctx )
143+ require .NoError (t , err )
144+ assert .Equal (t , config .Size (10 ), a )
145+ assert .Error (t , rl .Use (ctx , 11 ))
146+ // update
147+ getter .On ("GetScoped" , mock .Anything , settings .ScopeGlobal , "foo" ).Return ("20" , nil ).Twice ()
148+ // re-validate
149+ a , err = rl .Available (ctx )
150+ require .NoError (t , err )
151+ assert .Equal (t , config .Size (20 ), a )
152+ assert .NoError (t , rl .Use (ctx , 11 ))
153+ }
154+
128155func TestMakeResourcePoolLimiter (t * testing.T ) {
129156 t .Parallel ()
130157 for _ , tt := range []struct {
0 commit comments