Check for lower

This commit is contained in:
Kegan Dougal 2024-06-04 17:22:43 +01:00
parent 17cb5f0376
commit 7ea0b711db

View File

@ -3,6 +3,7 @@ package syncv3
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"strconv"
"testing" "testing"
"time" "time"
@ -468,7 +469,7 @@ func TestExtensionToDeviceSequence(t *testing.T) {
}, },
}) })
hiSince := "999999" hiSince := 999999
res := v3.mustDoV3Request(t, aliceToken, sync3.Request{ res := v3.mustDoV3Request(t, aliceToken, sync3.Request{
Lists: map[string]sync3.RequestList{"a": { Lists: map[string]sync3.RequestList{"a": {
Ranges: sync3.SliceRanges{ Ranges: sync3.SliceRanges{
@ -478,14 +479,18 @@ func TestExtensionToDeviceSequence(t *testing.T) {
Extensions: extensions.Request{ Extensions: extensions.Request{
ToDevice: &extensions.ToDeviceRequest{ ToDevice: &extensions.ToDeviceRequest{
Core: extensions.Core{Enabled: &boolTrue}, Core: extensions.Core{Enabled: &boolTrue},
Since: hiSince, Since: fmt.Sprintf("%d", hiSince),
}, },
}, },
}) })
m.MatchResponse(t, res, m.MatchList("a", m.MatchV3Count(0)), m.MatchToDeviceMessages(toDeviceMsgs), func(res *sync3.Response) error { m.MatchResponse(t, res, m.MatchList("a", m.MatchV3Count(0)), m.MatchToDeviceMessages(toDeviceMsgs), func(res *sync3.Response) error {
// ensure that we return a lower numbered since token // ensure that we return a lower numbered since token
if res.Extensions.ToDevice.NextBatch == hiSince { got, err := strconv.Atoi(res.Extensions.ToDevice.NextBatch)
return fmt.Errorf("next_batch got %v wanted lower", hiSince) if err != nil {
return err
}
if got >= hiSince {
return fmt.Errorf("next_batch got %v wanted lower than %v", got, hiSince)
} }
return nil return nil
}) })