Skip to content

Commit 6ca9f77

Browse files
committed
fix (#661): Add NewClientOptionsReader for mocking purposes.
1 parent 5786441 commit 6ca9f77

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

options_reader.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ type ClientOptionsReader struct {
3030
options *ClientOptions
3131
}
3232

33+
// NewOptionsReader creates a ClientOptionsReader, this should only be used for mocking purposes.
34+
// An example implementation:
35+
//
36+
// func (c *mqttClientMock) OptionsReader() mqtt.ClientOptionsReader {
37+
// opts := mqtt.NewClientOptions()
38+
// opts.UserName = "TestUserName"
39+
// return mqtt.NewOptionsReader(opts)
40+
// }
41+
func NewOptionsReader(o *ClientOptions) ClientOptionsReader {
42+
return ClientOptionsReader{
43+
options: o,
44+
}
45+
}
46+
3347
// Servers returns a slice of the servers defined in the clientoptions
3448
func (r *ClientOptionsReader) Servers() []*url.URL {
3549
s := make([]*url.URL, len(r.options.Servers))

0 commit comments

Comments
 (0)