hybridgroup.gobot/platforms/bleclient/ble_client_adaptor_options_...

28 lines
639 B
Go
Raw Permalink Normal View History

2024-02-12 00:01:24 +08:00
package bleclient
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestWithDebug(t *testing.T) {
// This is a general test, that options are applied by using the WithDebug() option.
// All other configuration options can also be tested by With..(val).apply(cfg).
// arrange & act
a := NewAdaptor("address", WithDebug())
// assert
assert.True(t, a.cfg.debug)
}
func TestWithScanTimeout(t *testing.T) {
// arrange
newTimeout := 2 * time.Second
cfg := &configuration{scanTimeout: 10 * time.Second}
// act
WithScanTimeout(newTimeout).apply(cfg)
// assert
assert.Equal(t, newTimeout, cfg.scanTimeout)
}