1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-24 13:48:49 +08:00
hybridgroup.gobot/platforms/bleclient/ble_client_adaptor_options_test.go
2024-02-11 17:01:24 +01:00

28 lines
639 B
Go

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)
}