@@ -47,6 +47,9 @@ func TestLoad_Defaults(t *testing.T) {
4747 if cfg .Timeout != 10 * time .Second {
4848 t .Errorf ("expected 10s timeout, got %v" , cfg .Timeout )
4949 }
50+ if cfg .RequestDelay != 0 {
51+ t .Errorf ("expected 0 request delay, got %v" , cfg .RequestDelay )
52+ }
5053 if cfg .ShutdownTimeout != 30 * time .Second {
5154 t .Errorf ("expected 30s shutdown timeout, got %v" , cfg .ShutdownTimeout )
5255 }
@@ -72,6 +75,7 @@ func TestLoad_CustomValues(t *testing.T) {
7275 os .Setenv ("MODBUS_CACHE_SERVE_STALE" , "true" )
7376 os .Setenv ("MODBUS_READONLY" , "false" )
7477 os .Setenv ("MODBUS_TIMEOUT" , "5s" )
78+ os .Setenv ("MODBUS_REQUEST_DELAY" , "100ms" )
7579 os .Setenv ("MODBUS_SHUTDOWN_TIMEOUT" , "60s" )
7680 os .Setenv ("LOG_LEVEL" , "DEBUG" )
7781
@@ -83,6 +87,7 @@ func TestLoad_CustomValues(t *testing.T) {
8387 os .Unsetenv ("MODBUS_CACHE_SERVE_STALE" )
8488 os .Unsetenv ("MODBUS_READONLY" )
8589 os .Unsetenv ("MODBUS_TIMEOUT" )
90+ os .Unsetenv ("MODBUS_REQUEST_DELAY" )
8691 os .Unsetenv ("MODBUS_SHUTDOWN_TIMEOUT" )
8792 os .Unsetenv ("LOG_LEVEL" )
8893 }()
@@ -110,6 +115,9 @@ func TestLoad_CustomValues(t *testing.T) {
110115 if cfg .Timeout != 5 * time .Second {
111116 t .Errorf ("expected 5s timeout, got %v" , cfg .Timeout )
112117 }
118+ if cfg .RequestDelay != 100 * time .Millisecond {
119+ t .Errorf ("expected 100ms request delay, got %v" , cfg .RequestDelay )
120+ }
113121 if cfg .ShutdownTimeout != 60 * time .Second {
114122 t .Errorf ("expected 60s shutdown timeout, got %v" , cfg .ShutdownTimeout )
115123 }
@@ -166,7 +174,7 @@ func TestLoad_InvalidDuration(t *testing.T) {
166174 os .Setenv ("MODBUS_UPSTREAM" , "localhost:502" )
167175 defer os .Unsetenv ("MODBUS_UPSTREAM" )
168176
169- tests := []string {"MODBUS_CACHE_TTL" , "MODBUS_TIMEOUT" , "MODBUS_SHUTDOWN_TIMEOUT" }
177+ tests := []string {"MODBUS_CACHE_TTL" , "MODBUS_TIMEOUT" , "MODBUS_REQUEST_DELAY" , " MODBUS_SHUTDOWN_TIMEOUT" }
170178 for _ , envVar := range tests {
171179 os .Setenv (envVar , "invalid" )
172180 _ , err := Load ()
0 commit comments