Selaa lähdekoodia

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

Willem van Bergen 11 vuotta sitten
vanhempi
commit
588d923398
1 muutettua tiedostoa jossa 10 lisäystä ja 0 poistoa
  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)