Skip to content

Commit 0581fd1

Browse files
committed
Add vhost
1 parent 6272999 commit 0581fd1

File tree

3 files changed

+15
-48
lines changed

3 files changed

+15
-48
lines changed

pkg/stream/enviroment.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,15 @@ func (envOptions *EnvironmentOptions) SetHost(host string) *EnvironmentOptions {
262262
return envOptions
263263
}
264264

265+
func (envOptions *EnvironmentOptions) SetVHost(vhost string) *EnvironmentOptions {
266+
if len(envOptions.ConnectionParameters) == 0 {
267+
envOptions.ConnectionParameters = append(envOptions.ConnectionParameters, &Broker{Vhost: vhost})
268+
} else {
269+
envOptions.ConnectionParameters[0].Vhost = vhost
270+
}
271+
return envOptions
272+
}
273+
265274
func (envOptions *EnvironmentOptions) SetTLSConfig(config *tls.Config) *EnvironmentOptions {
266275
if len(envOptions.ConnectionParameters) == 0 {
267276
envOptions.ConnectionParameters = append(envOptions.ConnectionParameters, &Broker{tlsConfig: config})

pkg/stream/enviroment_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@ var _ = Describe("Environment test", func() {
188188
Expect(err).To(Equal(VirtualHostAccessFailure))
189189
})
190190

191+
192+
It("Connection Vhost not exist", func() {
193+
_, err := NewEnvironment(NewEnvironmentOptions().SetVHost("VHOSTNOEXIST"))
194+
Expect(err).To(Equal(VirtualHostAccessFailure))
195+
})
196+
191197
It("Connection Vhost exists", func() {
192198
_, err := NewEnvironment(NewEnvironmentOptions().
193199
SetUri("rabbitmq-stream://guest:guest@localhost:5552/" + testVhost))

pkg/stream/mocks/producer_mock.go

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)