|
|
@@ -0,0 +1,29 @@
|
|
|
+package protocol
|
|
|
+
|
|
|
+import "testing"
|
|
|
+
|
|
|
+var (
|
|
|
+ metadataRequestNoTopics = []byte{
|
|
|
+ 0x00, 0x00, 0x00, 0x00}
|
|
|
+
|
|
|
+ metadataRequestOneTopic = []byte{
|
|
|
+ 0x00, 0x00, 0x00, 0x01,
|
|
|
+ 0x00, 0x06, 't', 'o', 'p', 'i', 'c', '1'}
|
|
|
+
|
|
|
+ metadataRequestThreeTopics = []byte{
|
|
|
+ 0x00, 0x00, 0x00, 0x03,
|
|
|
+ 0x00, 0x03, 'f', 'o', 'o',
|
|
|
+ 0x00, 0x03, 'b', 'a', 'r',
|
|
|
+ 0x00, 0x03, 'b', 'a', 'z'}
|
|
|
+)
|
|
|
+
|
|
|
+func TestMetadataRequest(t *testing.T) {
|
|
|
+ request := new(MetadataRequest)
|
|
|
+ testEncodable(t, "no topics", request, metadataRequestNoTopics)
|
|
|
+
|
|
|
+ request.Topics = []string{"topic1"}
|
|
|
+ testEncodable(t, "one topic", request, metadataRequestOneTopic)
|
|
|
+
|
|
|
+ request.Topics = []string{"foo", "bar", "baz"}
|
|
|
+ testEncodable(t, "three topics", request, metadataRequestThreeTopics)
|
|
|
+}
|