MCPcopy
hub / github.com/IBM/sarama / TestConsumerConfigValidates

Function TestConsumerConfigValidates

config_test.go:470–503  ·  config_test.go::TestConsumerConfigValidates
(t *testing.T)

Source from the content-addressed store, hash-verified

468}
469
470func TestConsumerConfigValidates(t *testing.T) {
471 tests := []struct {
472 name string
473 cfg func(*Config)
474 err string
475 }{
476 {
477 "ReadCommitted Version",
478 func(cfg *Config) {
479 cfg.Version = V0_10_0_0
480 cfg.Consumer.IsolationLevel = ReadCommitted
481 },
482 "ReadCommitted requires Version >= V0_11_0_0",
483 },
484 {
485 "Incorrect isolation level",
486 func(cfg *Config) {
487 cfg.Version = V0_11_0_0
488 cfg.Consumer.IsolationLevel = IsolationLevel(42)
489 },
490 "Consumer.IsolationLevel must be ReadUncommitted or ReadCommitted",
491 },
492 }
493
494 for i, test := range tests {
495 c := NewTestConfig()
496 test.cfg(c)
497 err := c.Validate()
498 var target ConfigurationError
499 if !errors.As(err, &target) || string(target) != test.err {
500 t.Errorf("[%d]:[%s] Expected %s, Got %s\n", i, test.name, test.err, err)
501 }
502 }
503}
504
505func TestLZ4ConfigValidation(t *testing.T) {
506 config := NewTestConfig()

Callers

nothing calls this directly

Calls 4

IsolationLevelTypeAlias · 0.85
ValidateMethod · 0.80
NewTestConfigFunction · 0.70
ErrorfMethod · 0.65

Tested by

no test coverage detected