Browse Source

Merge pull request #268 from Shopify/test_newclient_returns_error

Add a test to make sure connection to a cluster that is completely down will return an error
Willem van Bergen 11 years ago
parent
commit
63d0341845
1 changed files with 10 additions and 0 deletions
  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)