Skip to content

Commit

Permalink
fix (#661): Add NewClientOptionsReader for mocking purposes.
Browse files Browse the repository at this point in the history
  • Loading branch information
avmunm committed Dec 19, 2023
1 parent 5786441 commit 6f31b3d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions options_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ type ClientOptionsReader struct {
options *ClientOptions
}

// NewOptionsReader creates a ClientOptionsReader, this should only be used for mocking purposes.
//
// An example implementation:
//
// func (c *mqttClientMock) OptionsReader() mqtt.ClientOptionsReader {
// opts := mqtt.NewClientOptions()
// opts.UserName = "TestUserName"
// return mqtt.NewOptionsReader(opts)
// }
func NewOptionsReader(o *ClientOptions) ClientOptionsReader {
return ClientOptionsReader{
options: o,
}
}

// Servers returns a slice of the servers defined in the clientoptions
func (r *ClientOptionsReader) Servers() []*url.URL {
s := make([]*url.URL, len(r.options.Servers))
Expand Down

0 comments on commit 6f31b3d

Please sign in to comment.