From fa97a3da1c44b77bbb965a18372d424bac77da30 Mon Sep 17 00:00:00 2001 From: Pawel Date: Fri, 5 Jul 2024 14:11:02 +0200 Subject: [PATCH] add additional checks --- test/integration/access_codes_test.go | 1 + test/integration/devices_test.go | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/test/integration/access_codes_test.go b/test/integration/access_codes_test.go index 7fe6651..d87ecb8 100644 --- a/test/integration/access_codes_test.go +++ b/test/integration/access_codes_test.go @@ -128,6 +128,7 @@ func TestAccessCodes(t *testing.T) { ) require.NoError(t, err) require.NotNil(t, createdAccessCodes, "Created access codes should not be nil") + assert.Len(t, createdAccessCodes, 1) assert.NotEmpty(t, createdAccessCodes, "Created access codes should not be empty") assert.Equal(t, len(deviceIds), len(createdAccessCodes)) diff --git a/test/integration/devices_test.go b/test/integration/devices_test.go index a6f9988..2ccaece 100644 --- a/test/integration/devices_test.go +++ b/test/integration/devices_test.go @@ -58,6 +58,7 @@ func TestDevices(t *testing.T) { require.NoError(t, err) assert.Len(t, devices, 2) + // query device with id devices, err = seam.Devices.List( ctx, &seamgo.DevicesListRequest{ @@ -76,6 +77,32 @@ func TestDevices(t *testing.T) { require.NoError(t, err) assert.Equal(t, device.DisplayName, deviceWithId.DisplayName) + // query device with name + device = getTestDevice(t, seam) + require.NotNil(t, device, "Test device should not be nil") + + deviceByName, err := seam.Devices.Get( + ctx, + &seamgo.DevicesGetRequest{ + Name: &device.DisplayName, + }, + ) + require.NoError(t, err) + assert.NotNil(t, deviceByName, "Device queried by name should not be nil") + assert.Equal(t, device.DisplayName, deviceByName.DisplayName) + + deviceByNameAndId, err := seam.Devices.Get( + ctx, + &seamgo.DevicesGetRequest{ + Name: &device.DisplayName, + DeviceId: &device.DeviceId, + }, + ) + require.NoError(t, err) + assert.NotNil(t, deviceByNameAndId, "Device queried by name and ID should not be nil") + assert.Equal(t, device.DisplayName, deviceByNameAndId.DisplayName) + assert.Equal(t, device.DeviceId, deviceByNameAndId.DeviceId) + locks, err := seam.Locks.List( ctx, nil,