From 73978b33eb63573ddc6065f92c783da3b490ddab Mon Sep 17 00:00:00 2001 From: Nick Cellino Date: Tue, 6 Feb 2024 11:15:29 -0500 Subject: [PATCH] Fix watch test --- internal/hcp/watch_test.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/internal/hcp/watch_test.go b/internal/hcp/watch_test.go index adb29f91a0..44078d54ea 100644 --- a/internal/hcp/watch_test.go +++ b/internal/hcp/watch_test.go @@ -73,12 +73,16 @@ func (suite *controllerSuite) TestLinkWatch_Ok() { WithData(suite.T(), linkData). Write(suite.T(), suite.client) + // The first event will always be the "end of snapshot" event + endOfSnapshotEvent := <-linkWatchCh + require.NotNil(suite.T(), endOfSnapshotEvent.GetEndOfSnapshot()) + select { case watchEvent := <-linkWatchCh: - require.Equal(suite.T(), pbresource.WatchEvent_OPERATION_UPSERT, watchEvent.Operation) - res := watchEvent.Resource + require.NotNil(suite.T(), watchEvent.GetUpsert()) + res := watchEvent.GetUpsert().GetResource() var upsertedLink pbhcp.Link - err := res.Data.UnmarshalTo(&upsertedLink) + err := res.GetData().UnmarshalTo(&upsertedLink) require.NoError(suite.T(), err) require.Equal(suite.T(), linkData.ClientId, upsertedLink.ClientId) require.Equal(suite.T(), linkData.ClientSecret, upsertedLink.ClientSecret) @@ -92,7 +96,7 @@ func (suite *controllerSuite) TestLinkWatch_Ok() { select { case watchEvent := <-linkWatchCh: - require.Equal(suite.T(), pbresource.WatchEvent_OPERATION_DELETE, watchEvent.Operation) + require.NotNil(suite.T(), watchEvent.GetDelete()) case <-time.After(time.Second): require.Fail(suite.T(), "nothing emitted on link watch channel for delete") }