MCPcopy
hub / github.com/redis/go-redis / TestReadTimeoutOptions

Function TestReadTimeoutOptions

options_test.go:231–250  ·  view source on GitHub ↗

Test ReadTimeout option initialization, including special values -1 and 0. And also test behaviour of WriteTimeout option, when it is not explicitly set and use ReadTimeout value.

(t *testing.T)

Source from the content-addressed store, hash-verified

229// And also test behaviour of WriteTimeout option, when it is not explicitly set and use
230// ReadTimeout value.
231func TestReadTimeoutOptions(t *testing.T) {
232 testDataInputOutputMap := map[time.Duration]time.Duration{
233 -1: 0 * time.Second,
234 0: 3 * time.Second,
235 1: 1 * time.Nanosecond,
236 3: 3 * time.Nanosecond,
237 }
238
239 for in, out := range testDataInputOutputMap {
240 o := &Options{ReadTimeout: in}
241 o.init()
242 if o.ReadTimeout != out {
243 t.Errorf("got %d instead of %d as ReadTimeout option", o.ReadTimeout, out)
244 }
245
246 if o.WriteTimeout != o.ReadTimeout {
247 t.Errorf("got %d instead of %d as WriteTimeout option", o.WriteTimeout, o.ReadTimeout)
248 }
249 }
250}
251
252func TestProtocolOptions(t *testing.T) {
253 testCasesMap := map[int]int{

Callers

nothing calls this directly

Calls 1

initMethod · 0.95

Tested by

no test coverage detected