Skip to content

Commit

Permalink
Merge pull request #662 from avmunm/fix-661-make-ClientOptionsReader-…
Browse files Browse the repository at this point in the history
…mockable

Add NewClientOptionsReader for mocking purposes.

closes #661
  • Loading branch information
MattBrittan authored Dec 19, 2023
2 parents 5786441 + 6f31b3d commit 6d8e0a7
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 6d8e0a7

Please sign in to comment.