]> git.giacomolli.uk - onehouse/blobdiff - driver/alamo/gateway_test.go
Poll and command shared Alamo thermostats
[onehouse] / driver / alamo / gateway_test.go
index 715e860d41e49f70f4926fe09d4bdb578b0793e5..ab004e0d3570a6724932d0d5875c2dbbcc900689 100644 (file)
@@ -85,3 +85,19 @@ func TestGatewayBoundsFakeClientOperationsAndReturnsFailures(t *testing.T) {
                require.ErrorIs(t, err, client.err)
        })
 }
+
+func TestGatewayDoesNotStartAtTheExactCommandDeadline(t *testing.T) {
+       synctest.Test(t, func(t *testing.T) {
+               client := &fakeGateway{states: []State{testState()}}
+               gateway := &gateway{client: client}
+               _, err := gateway.status(t.Context())
+               require.NoError(t, err)
+
+               ctx, cancel := context.WithTimeout(t.Context(), 6*time.Second)
+               defer cancel()
+
+               _, err = gateway.action(ctx, testMAC, Action{})
+               require.ErrorIs(t, err, context.DeadlineExceeded)
+               require.Len(t, client.starts, 1)
+       })
+}