From 977900b6f23e980986c7baa60c8181180c968b51 Mon Sep 17 00:00:00 2001 From: Matt Toohey Date: Mon, 9 Dec 2024 14:47:46 +1100 Subject: [PATCH] fix test, lint --- backend/controller/dal/dal_test.go | 11 +++++------ backend/timeline/service.go | 10 +++++----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/backend/controller/dal/dal_test.go b/backend/controller/dal/dal_test.go index 7d17ff30f5..446d0cb63d 100644 --- a/backend/controller/dal/dal_test.go +++ b/backend/controller/dal/dal_test.go @@ -3,7 +3,7 @@ package dal import ( "bytes" "context" - "net/http" + "net/url" "sync" "testing" "time" @@ -13,7 +13,7 @@ import ( "golang.org/x/sync/errgroup" "github.com/TBD54566975/ftl/backend/controller/artefacts" - "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/timeline/v1/timelinev1connect" + "github.com/TBD54566975/ftl/backend/timeline" dalmodel "github.com/TBD54566975/ftl/backend/controller/dal/model" "github.com/TBD54566975/ftl/backend/controller/pubsub" @@ -21,15 +21,15 @@ import ( "github.com/TBD54566975/ftl/backend/libdal" "github.com/TBD54566975/ftl/internal/log" "github.com/TBD54566975/ftl/internal/model" - "github.com/TBD54566975/ftl/internal/rpc" "github.com/TBD54566975/ftl/internal/schema" "github.com/TBD54566975/ftl/internal/sha256" ) func TestDAL(t *testing.T) { ctx := log.ContextWithNewDefaultLogger(context.Background()) - timelineClient := timelinev1connect.NewTimelineServiceClient(http.DefaultClient, "http://localhost:8080") - ctx = rpc.ContextWithClient(ctx, timelineClient) + timelineEndpoint, err := url.Parse("http://localhost:8080") + assert.NoError(t, err) + ctx = timeline.ContextWithClient(ctx, timeline.NewClient(ctx, timelineEndpoint)) conn := sqltest.OpenForTesting(ctx, t) pubSub := pubsub.New(ctx, conn, optional.None[pubsub.AsyncCallListener]()) @@ -38,7 +38,6 @@ func TestDAL(t *testing.T) { var testContent = bytes.Repeat([]byte("sometestcontentthatislongerthanthereadbuffer"), 100) var testSHA = sha256.Sum(testContent) - var err error deploymentChangesCh := dal.DeploymentChanges.Subscribe(nil) deploymentChanges := []DeploymentNotification{} wg := errgroup.Group{} diff --git a/backend/timeline/service.go b/backend/timeline/service.go index 7d7201e7d6..30de710913 100644 --- a/backend/timeline/service.go +++ b/backend/timeline/service.go @@ -190,16 +190,16 @@ func (s *service) StreamTimeline(ctx context.Context, req *connect.Request[timel timelineReq := req.Msg.Query // Default to last 1 day of events - var lastEventId optional.Option[int64] + var lastEventID optional.Option[int64] for { newQuery := timelineReq // We always want ascending order for the underlying query. newQuery.Order = timelinepb.GetTimelineRequest_ORDER_ASC - if _, ok := lastEventId.Get(); ok { + if _, ok := lastEventID.Get(); ok { newQuery.Filters = append(newQuery.Filters, &timelinepb.GetTimelineRequest_Filter{ Filter: &timelinepb.GetTimelineRequest_Filter_Id{ Id: &timelinepb.GetTimelineRequest_IDFilter{ - HigherThan: lastEventId.Ptr(), + HigherThan: lastEventID.Ptr(), }, }, }) @@ -212,13 +212,13 @@ func (s *service) StreamTimeline(ctx context.Context, req *connect.Request[timel newEvents := make([]*timelinepb.Event, 0, len(resp.Msg.Events)) for _, event := range resp.Msg.Events { - if lastEventId, ok := lastEventId.Get(); !ok || event.Id != lastEventId { + if lastEventID, ok := lastEventID.Get(); !ok || event.Id != lastEventID { // This is not a duplicate event. newEvents = append(newEvents, event) } } if len(newEvents) > 0 { - lastEventId = optional.Some(newEvents[len(newEvents)-1].Id) + lastEventID = optional.Some(newEvents[len(newEvents)-1].Id) if !ascending { // Original query was for descending order, so reverse the events.