Browse Source

Standardize on underscores

Evan Huus 11 years ago
parent
commit
7dca867d92
3 changed files with 28 additions and 28 deletions
  1. 14 14
      client_test.go
  2. 8 8
      consumer_test.go
  3. 6 6
      producer_test.go

+ 14 - 14
client_test.go

@@ -13,7 +13,7 @@ func TestSimpleClient(t *testing.T) {
 	// Only one response needed, an empty metadata response
 	responses <- []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
 
-	client, err := NewClient("clientID", []string{mockBroker.Addr()}, nil)
+	client, err := NewClient("client_id", []string{mockBroker.Addr()}, nil)
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -37,7 +37,7 @@ func TestClientExtraBrokers(t *testing.T) {
 	binary.BigEndian.PutUint32(response[19:], uint32(mockExtra.Port()))
 	responses <- response
 
-	client, err := NewClient("clientID", []string{mockBroker.Addr()}, nil)
+	client, err := NewClient("client_id", []string{mockBroker.Addr()}, nil)
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -60,7 +60,7 @@ func TestClientMetadata(t *testing.T) {
 
 		0x00, 0x00, 0x00, 0x01,
 		0x00, 0x00,
-		0x00, 0x07, 'm', 'y', 'T', 'o', 'p', 'i', 'c',
+		0x00, 0x08, 'm', 'y', '_', 't', 'o', 'p', 'i', 'c',
 		0x00, 0x00, 0x00, 0x01,
 		0x00, 0x00,
 		0x00, 0x00, 0x00, 0x00,
@@ -70,24 +70,24 @@ func TestClientMetadata(t *testing.T) {
 	binary.BigEndian.PutUint32(response[19:], uint32(mockExtra.Port()))
 	responses <- response
 
-	client, err := NewClient("clientID", []string{mockBroker.Addr()}, nil)
+	client, err := NewClient("client_id", []string{mockBroker.Addr()}, nil)
 	if err != nil {
 		t.Fatal(err)
 	}
 	defer client.Close()
 
-	parts, err := client.partitions("myTopic")
+	parts, err := client.partitions("my_topic")
 	if err != nil {
 		t.Error(err)
 	} else if len(parts) != 1 || parts[0] != 0 {
-		t.Error("Client returned incorrect partitions for myTopic:", parts)
+		t.Error("Client returned incorrect partitions for my_topic:", parts)
 	}
 
-	tst, err := client.leader("myTopic", 0)
+	tst, err := client.leader("my_topic", 0)
 	if err != nil {
 		t.Error(err)
 	} else if tst.ID() != 5 {
-		t.Error("Leader for myTopic had incorrect ID.")
+		t.Error("Leader for my_topic had incorrect ID.")
 	}
 }
 
@@ -112,7 +112,7 @@ func TestClientRefreshBehaviour(t *testing.T) {
 		0x00, 0x00, 0x00, 0x00,
 		0x00, 0x00, 0x00, 0x01,
 		0x00, 0x00,
-		0x00, 0x07, 'm', 'y', 'T', 'o', 'p', 'i', 'c',
+		0x00, 0x08, 'm', 'y', '_', 't', 'o', 'p', 'i', 'c',
 		0x00, 0x00, 0x00, 0x01,
 		0x00, 0x05,
 		0x00, 0x00, 0x00, 0x0e,
@@ -123,7 +123,7 @@ func TestClientRefreshBehaviour(t *testing.T) {
 		0x00, 0x00, 0x00, 0x00,
 		0x00, 0x00, 0x00, 0x01,
 		0x00, 0x00,
-		0x00, 0x07, 'm', 'y', 'T', 'o', 'p', 'i', 'c',
+		0x00, 0x08, 'm', 'y', '_', 't', 'o', 'p', 'i', 'c',
 		0x00, 0x00, 0x00, 0x01,
 		0x00, 0x00,
 		0x00, 0x00, 0x00, 0x0b,
@@ -137,18 +137,18 @@ func TestClientRefreshBehaviour(t *testing.T) {
 	}
 	defer client.Close()
 
-	parts, err := client.partitions("myTopic")
+	parts, err := client.partitions("my_topic")
 	if err != nil {
 		t.Error(err)
 	} else if len(parts) != 1 || parts[0] != 0xb {
-		t.Error("Client returned incorrect partitions for myTopic:", parts)
+		t.Error("Client returned incorrect partitions for my_topic:", parts)
 	}
 
-	tst, err := client.leader("myTopic", 0xb)
+	tst, err := client.leader("my_topic", 0xb)
 	if err != nil {
 		t.Error(err)
 	} else if tst.ID() != 0xaa {
-		t.Error("Leader for myTopic had incorrect ID.")
+		t.Error("Leader for my_topic had incorrect ID.")
 	}
 
 	client.disconnectBroker(tst)

+ 8 - 8
consumer_test.go

@@ -23,7 +23,7 @@ func TestSimpleConsumer(t *testing.T) {
 		0x00, 0x00, 0x00, 0x00,
 		0x00, 0x00, 0x00, 0x01,
 		0x00, 0x00,
-		0x00, 0x07, 'm', 'y', 'T', 'o', 'p', 'i', 'c',
+		0x00, 0x08, 'm', 'y', '_', 't', 'o', 'p', 'i', 'c',
 		0x00, 0x00, 0x00, 0x01,
 		0x00, 0x00,
 		0x00, 0x00, 0x00, 0x00,
@@ -36,7 +36,7 @@ func TestSimpleConsumer(t *testing.T) {
 		for i := 0; i < 10; i++ {
 			msg := []byte{
 				0x00, 0x00, 0x00, 0x01,
-				0x00, 0x07, 'm', 'y', 'T', 'o', 'p', 'i', 'c',
+				0x00, 0x08, 'm', 'y', '_', 't', 'o', 'p', 'i', 'c',
 				0x00, 0x00, 0x00, 0x01,
 				0x00, 0x00, 0x00, 0x00,
 				0x00, 0x00,
@@ -51,12 +51,12 @@ func TestSimpleConsumer(t *testing.T) {
 				0x00,
 				0xFF, 0xFF, 0xFF, 0xFF,
 				0x00, 0x00, 0x00, 0x02, 0x00, 0xEE}
-			binary.BigEndian.PutUint64(msg[35:], uint64(i))
+			binary.BigEndian.PutUint64(msg[36:], uint64(i))
 			extraResponses <- msg
 		}
 		extraResponses <- []byte{
 			0x00, 0x00, 0x00, 0x01,
-			0x00, 0x07, 'm', 'y', 'T', 'o', 'p', 'i', 'c',
+			0x00, 0x08, 'm', 'y', '_', 't', 'o', 'p', 'i', 'c',
 			0x00, 0x00, 0x00, 0x01,
 			0x00, 0x00, 0x00, 0x00,
 			0x00, 0x00,
@@ -64,13 +64,13 @@ func TestSimpleConsumer(t *testing.T) {
 			0x00, 0x00, 0x00, 0x00}
 	}()
 
-	client, err := NewClient("clientID", []string{mockBroker.Addr()}, nil)
+	client, err := NewClient("client_id", []string{mockBroker.Addr()}, nil)
 	if err != nil {
 		t.Fatal(err)
 	}
 	defer client.Close()
 
-	consumer, err := NewConsumer(client, "myTopic", 0, "myConsumerGroup", nil)
+	consumer, err := NewConsumer(client, "my_topic", 0, "my_consumer_group", nil)
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -88,7 +88,7 @@ func TestSimpleConsumer(t *testing.T) {
 }
 
 func ExampleConsumer() {
-	client, err := NewClient("myClient", []string{"localhost:9092"}, nil)
+	client, err := NewClient("my_client", []string{"localhost:9092"}, nil)
 	if err != nil {
 		panic(err)
 	} else {
@@ -96,7 +96,7 @@ func ExampleConsumer() {
 	}
 	defer client.Close()
 
-	consumer, err := NewConsumer(client, "myTopic", 0, "myConsumerGroup", nil)
+	consumer, err := NewConsumer(client, "my_topic", 0, "my_consumer_group", nil)
 	if err != nil {
 		panic(err)
 	} else {

+ 6 - 6
producer_test.go

@@ -22,7 +22,7 @@ func TestSimpleProducer(t *testing.T) {
 		0x00, 0x00, 0x00, 0x00,
 		0x00, 0x00, 0x00, 0x01,
 		0x00, 0x00,
-		0x00, 0x07, 'm', 'y', 'T', 'o', 'p', 'i', 'c',
+		0x00, 0x08, 'm', 'y', '_', 't', 'o', 'p', 'i', 'c',
 		0x00, 0x00, 0x00, 0x01,
 		0x00, 0x00,
 		0x00, 0x00, 0x00, 0x00,
@@ -35,7 +35,7 @@ func TestSimpleProducer(t *testing.T) {
 		for i := 0; i < 10; i++ {
 			msg := []byte{
 				0x00, 0x00, 0x00, 0x01,
-				0x00, 0x07, 'm', 'y', 'T', 'o', 'p', 'i', 'c',
+				0x00, 0x08, 'm', 'y', '_', 't', 'o', 'p', 'i', 'c',
 				0x00, 0x00, 0x00, 0x01,
 				0x00, 0x00, 0x00, 0x00,
 				0x00, 0x00,
@@ -45,13 +45,13 @@ func TestSimpleProducer(t *testing.T) {
 		}
 	}()
 
-	client, err := NewClient("clientID", []string{mockBroker.Addr()}, nil)
+	client, err := NewClient("client_id", []string{mockBroker.Addr()}, nil)
 	if err != nil {
 		t.Fatal(err)
 	}
 	defer client.Close()
 
-	producer, err := NewProducer(client, "myTopic", &ProducerConfig{RequiredAcks: WAIT_FOR_LOCAL})
+	producer, err := NewProducer(client, "my_topic", &ProducerConfig{RequiredAcks: WAIT_FOR_LOCAL})
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -66,7 +66,7 @@ func TestSimpleProducer(t *testing.T) {
 }
 
 func ExampleProducer() {
-	client, err := NewClient("myClient", []string{"localhost:9092"}, nil)
+	client, err := NewClient("my_client", []string{"localhost:9092"}, nil)
 	if err != nil {
 		panic(err)
 	} else {
@@ -74,7 +74,7 @@ func ExampleProducer() {
 	}
 	defer client.Close()
 
-	producer, err := NewProducer(client, "myTopic", &ProducerConfig{RequiredAcks: WAIT_FOR_LOCAL})
+	producer, err := NewProducer(client, "my_topic", &ProducerConfig{RequiredAcks: WAIT_FOR_LOCAL})
 	if err != nil {
 		panic(err)
 	}