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

Function TestNetConfigValidates

config_test.go:64–271  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

62}
63
64func TestNetConfigValidates(t *testing.T) {
65 tests := []struct {
66 name string
67 cfg func(*Config) // resorting to using a function as a param because of internal composite structs
68 err string
69 }{
70 {
71 "OpenRequests",
72 func(cfg *Config) {
73 cfg.Net.MaxOpenRequests = 0
74 },
75 "Net.MaxOpenRequests must be > 0",
76 },
77 {
78 "DialTimeout",
79 func(cfg *Config) {
80 cfg.Net.DialTimeout = 0
81 },
82 "Net.DialTimeout must be > 0",
83 },
84 {
85 "ReadTimeout",
86 func(cfg *Config) {
87 cfg.Net.ReadTimeout = 0
88 },
89 "Net.ReadTimeout must be > 0",
90 },
91 {
92 "WriteTimeout",
93 func(cfg *Config) {
94 cfg.Net.WriteTimeout = 0
95 },
96 "Net.WriteTimeout must be > 0",
97 },
98 {
99 "SASL.User",
100 func(cfg *Config) {
101 cfg.Net.SASL.Enable = true
102 cfg.Net.SASL.User = ""
103 },
104 "Net.SASL.User must not be empty when SASL is enabled",
105 },
106 {
107 "SASL.Password",
108 func(cfg *Config) {
109 cfg.Net.SASL.Enable = true
110 cfg.Net.SASL.User = "user"
111 cfg.Net.SASL.Password = ""
112 },
113 "Net.SASL.Password must not be empty when SASL is enabled",
114 },
115 {
116 "SASL.Mechanism - Invalid mechanism type",
117 func(cfg *Config) {
118 cfg.Net.SASL.Enable = true
119 cfg.Net.SASL.Mechanism = "AnIncorrectSASLMechanism"
120 cfg.Net.SASL.TokenProvider = &DummyTokenProvider{}
121 },

Callers

nothing calls this directly

Calls 3

ValidateMethod · 0.80
NewTestConfigFunction · 0.70
ErrorfMethod · 0.65

Tested by

no test coverage detected