MCPcopy
hub / github.com/segmentio/kafka-go / TestDialerResolver

Function TestDialerResolver

dialer_test.go:306–395  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

304}
305
306func TestDialerResolver(t *testing.T) {
307 ctx := context.TODO()
308
309 tests := []struct {
310 scenario string
311 address string
312 resolver map[string][]string
313 }{
314 {
315 scenario: "resolve domain to ip",
316 address: "example.com",
317 resolver: map[string][]string{
318 "example.com": {"127.0.0.1"},
319 },
320 },
321 {
322 scenario: "resolve domain to ip and port",
323 address: "example.com",
324 resolver: map[string][]string{
325 "example.com": {"127.0.0.1:9092"},
326 },
327 },
328 {
329 scenario: "resolve domain with port to ip",
330 address: "example.com:9092",
331 resolver: map[string][]string{
332 "example.com": {"127.0.0.1:9092"},
333 },
334 },
335 {
336 scenario: "resolve domain with port to ip with different port",
337 address: "example.com:9092",
338 resolver: map[string][]string{
339 "example.com": {"127.0.0.1:80"},
340 },
341 },
342 {
343 scenario: "resolve domain with port to ip",
344 address: "example.com:9092",
345 resolver: map[string][]string{
346 "example.com": {"127.0.0.1"},
347 },
348 },
349 }
350
351 for _, test := range tests {
352 t.Run(test.scenario, func(t *testing.T) {
353 topic := makeTopic()
354 createTopic(t, topic, 1)
355 defer deleteTopic(t, topic)
356
357 d := Dialer{
358 Resolver: &mockResolver{addrs: test.resolver},
359 }
360
361 // Write a message to ensure the partition gets created.
362 w := NewWriter(WriterConfig{
363 Brokers: []string{"localhost:9092"},

Callers

nothing calls this directly

Calls 8

WriteMessagesMethod · 0.95
CloseMethod · 0.95
LookupPartitionsMethod · 0.95
createTopicFunction · 0.85
deleteTopicFunction · 0.85
NewWriterFunction · 0.85
makeTopicFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected