From b4e12e5e0745719a6c82b529689b4eb86e4b3f5c Mon Sep 17 00:00:00 2001 From: hugoShaka Date: Mon, 4 Nov 2024 09:59:17 -0500 Subject: [PATCH] fix tests --- lib/services/local/autoupdate_test.go | 10 ++++++++-- tool/tctl/common/edit_command_test.go | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/services/local/autoupdate_test.go b/lib/services/local/autoupdate_test.go index ae858d65cc47c..a992322472975 100644 --- a/lib/services/local/autoupdate_test.go +++ b/lib/services/local/autoupdate_test.go @@ -93,8 +93,11 @@ func TestAutoUpdateServiceConfigCRUD(t *testing.T) { var notFoundError *trace.NotFoundError require.ErrorAs(t, err, ¬FoundError) + // If we try to conditionally update a missing resource, we receive + // a CompareFailed instead of a NotFound. + var revisionMismatchError *trace.CompareFailedError _, err = service.UpdateAutoUpdateConfig(ctx, config) - require.ErrorAs(t, err, ¬FoundError) + require.ErrorAs(t, err, &revisionMismatchError) } // TestAutoUpdateServiceVersionCRUD verifies get/create/update/upsert/delete methods of the backend service @@ -155,8 +158,11 @@ func TestAutoUpdateServiceVersionCRUD(t *testing.T) { var notFoundError *trace.NotFoundError require.ErrorAs(t, err, ¬FoundError) + // If we try to conditionally update a missing resource, we receive + // a CompareFailed instead of a NotFound. + var revisionMismatchError *trace.CompareFailedError _, err = service.UpdateAutoUpdateVersion(ctx, version) - require.ErrorAs(t, err, ¬FoundError) + require.ErrorAs(t, err, &revisionMismatchError) } // TestAutoUpdateServiceInvalidNameCreate verifies that configuration and version diff --git a/tool/tctl/common/edit_command_test.go b/tool/tctl/common/edit_command_test.go index c0ffbf342a485..7d3ddc98eabab 100644 --- a/tool/tctl/common/edit_command_test.go +++ b/tool/tctl/common/edit_command_test.go @@ -574,7 +574,7 @@ func testEditAutoUpdateConfig(t *testing.T, clt *authclient.Client) { require.NoError(t, err) serviceClient := autoupdatev1pb.NewAutoUpdateServiceClient(clt.GetConnection()) - _, err = serviceClient.CreateAutoUpdateConfig(ctx, &autoupdatev1pb.CreateAutoUpdateConfigRequest{Config: initial}) + initial, err = serviceClient.CreateAutoUpdateConfig(ctx, &autoupdatev1pb.CreateAutoUpdateConfigRequest{Config: initial}) require.NoError(t, err, "creating initial autoupdate config") editor := func(name string) error { @@ -616,7 +616,7 @@ func testEditAutoUpdateVersion(t *testing.T, clt *authclient.Client) { require.NoError(t, err) serviceClient := autoupdatev1pb.NewAutoUpdateServiceClient(clt.GetConnection()) - _, err = serviceClient.CreateAutoUpdateVersion(ctx, &autoupdatev1pb.CreateAutoUpdateVersionRequest{Version: initial}) + initial, err = serviceClient.CreateAutoUpdateVersion(ctx, &autoupdatev1pb.CreateAutoUpdateVersionRequest{Version: initial}) require.NoError(t, err, "creating initial autoupdate version") editor := func(name string) error {