Explorar o código

Add a test to make sure connection to a cluster that is completely down wil return an error

Willem van Bergen %!s(int64=11) %!d(string=hai) anos
pai
achega
588d923398
Modificáronse 1 ficheiros con 10 adicións e 0 borrados
  1. 10 0
      functional_test.go

+ 10 - 0
functional_test.go

@@ -43,6 +43,16 @@ func checkKafkaAvailability(t *testing.T) {
 	}
 }
 
+func TestFuncConnectionFailure(t *testing.T) {
+	config := NewClientConfig()
+	config.MetadataRetries = 1
+
+	_, err := NewClient("test", []string{"localhost:9000"}, config)
+	if err != OutOfBrokers {
+		t.Fatal("Expected returned error to be OutOfBrokers, but was: ", err)
+	}
+}
+
 func TestFuncProducing(t *testing.T) {
 	config := NewProducerConfig()
 	testProducingMessages(t, config)