github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/chat/maps/track_test.go (about)

     1  package maps
     2  
     3  import (
     4  	"testing"
     5  	"time"
     6  
     7  	"github.com/keybase/client/go/protocol/chat1"
     8  	"github.com/stretchr/testify/require"
     9  )
    10  
    11  func TestLocationTrackMaxCoords(t *testing.T) {
    12  	convID := chat1.ConversationID([]byte{0, 0, 1})
    13  	msgID := chat1.MessageID(5)
    14  	endTime := time.Now().Add(time.Hour)
    15  	tr := newLocationTrack(convID, msgID, endTime, false, 2, false)
    16  	firstCoord := chat1.Coordinate{Lat: 0, Lon: 1}
    17  	tr.updateCh <- chat1.Coordinate{Lat: 40.678, Lon: -73.98}
    18  	tr.updateCh <- chat1.Coordinate{Lat: 40.678, Lon: -73.99}
    19  	secondCoord := chat1.Coordinate{Lat: 50.678, Lon: -63.98}
    20  	tr.updateCh <- secondCoord
    21  	latestCoord := chat1.Coordinate{Lat: 30.678, Lon: -93.98}
    22  	tr.updateCh <- latestCoord
    23  	tr.Drain(firstCoord)
    24  	coords := tr.GetCoords()
    25  	require.Equal(t, []chat1.Coordinate{firstCoord, secondCoord, latestCoord}, coords)
    26  }