forked from bsm/sarama-cluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_test.go
31 lines (24 loc) · 799 Bytes
/
client_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package cluster
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Client", func() {
var subject *Client
BeforeEach(func() {
var err error
subject, err = NewClient(testKafkaAddrs, nil)
Expect(err).NotTo(HaveOccurred())
})
It("should not allow to share clients across multiple consumers", func() {
c1, err := NewConsumerFromClient(subject, testGroup, testTopics)
Expect(err).NotTo(HaveOccurred())
defer c1.Close()
_, err = NewConsumerFromClient(subject, testGroup, testTopics)
Expect(err).To(MatchError("cluster: client is already used by another consumer"))
Expect(c1.Close()).To(Succeed())
c2, err := NewConsumerFromClient(subject, testGroup, testTopics)
Expect(err).NotTo(HaveOccurred())
Expect(c2.Close()).To(Succeed())
})
})