metadata_request_test.go 720 B

1234567891011121314151617181920212223242526272829
  1. package sarama
  2. import "testing"
  3. var (
  4. metadataRequestNoTopics = []byte{
  5. 0x00, 0x00, 0x00, 0x00}
  6. metadataRequestOneTopic = []byte{
  7. 0x00, 0x00, 0x00, 0x01,
  8. 0x00, 0x06, 't', 'o', 'p', 'i', 'c', '1'}
  9. metadataRequestThreeTopics = []byte{
  10. 0x00, 0x00, 0x00, 0x03,
  11. 0x00, 0x03, 'f', 'o', 'o',
  12. 0x00, 0x03, 'b', 'a', 'r',
  13. 0x00, 0x03, 'b', 'a', 'z'}
  14. )
  15. func TestMetadataRequest(t *testing.T) {
  16. request := new(MetadataRequest)
  17. testRequest(t, "no topics", request, metadataRequestNoTopics)
  18. request.Topics = []string{"topic1"}
  19. testRequest(t, "one topic", request, metadataRequestOneTopic)
  20. request.Topics = []string{"foo", "bar", "baz"}
  21. testRequest(t, "three topics", request, metadataRequestThreeTopics)
  22. }