From 980b920261587fef51ba74452a18f74fd4c8fc82 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Tue, 29 Nov 2022 15:02:03 +0100 Subject: testhelper: Convert `GitalyOrPraefectMessage` to use generics The helper function `GitalyOrPraefectMessage()` will return either one of two messages depending on whether we execute with Praefect as proxy or not. It is more generally useful than that though as we may also want to check other object types. And now that we can use generics it is needlessly tied to a specific object type. Convert the function to accept any objects as input by using generics and rename it to `GitalyOrPraefect()`. --- internal/gitaly/service/blob/get_blob_test.go | 6 ++-- internal/gitaly/service/blob/lfs_pointers_test.go | 2 +- .../cleanup/apply_bfg_object_map_stream_test.go | 2 +- .../service/commit/check_objects_exist_test.go | 2 +- .../gitaly/service/commit/commit_messages_test.go | 2 +- .../service/commit/commit_signatures_test.go | 2 +- .../service/commit/commits_by_message_test.go | 4 +-- .../gitaly/service/commit/count_commits_test.go | 4 +-- .../service/commit/count_diverging_commits_test.go | 4 +-- .../commit/filter_shas_with_signatures_test.go | 2 +- .../gitaly/service/commit/find_all_commits_test.go | 4 +-- internal/gitaly/service/commit/find_commit_test.go | 4 +-- .../gitaly/service/commit/find_commits_test.go | 2 +- internal/gitaly/service/commit/isancestor_test.go | 4 +-- internal/gitaly/service/commit/languages_test.go | 2 +- .../service/commit/last_commit_for_path_test.go | 4 +-- .../gitaly/service/commit/list_all_commits_test.go | 2 +- .../service/commit/list_commits_by_oid_test.go | 2 +- .../commit/list_commits_by_ref_name_test.go | 2 +- .../gitaly/service/commit/list_commits_test.go | 2 +- internal/gitaly/service/commit/list_files_test.go | 6 ++-- .../commit/list_last_commits_for_tree_test.go | 4 +-- internal/gitaly/service/commit/raw_blame_test.go | 4 +-- internal/gitaly/service/commit/stats_test.go | 8 +++--- .../gitaly/service/commit/tree_entries_test.go | 4 +-- internal/gitaly/service/commit/tree_entry_test.go | 4 +-- .../service/conflicts/list_conflict_files_test.go | 2 +- .../service/conflicts/resolve_conflicts_test.go | 2 +- internal/gitaly/service/diff/commit_test.go | 4 +-- .../gitaly/service/diff/find_changed_paths_test.go | 6 ++-- internal/gitaly/service/diff/numstat_test.go | 6 ++-- .../gitaly/service/objectpool/alternates_test.go | 2 +- internal/gitaly/service/objectpool/get_test.go | 2 +- .../gitaly/service/operations/apply_patch_test.go | 2 +- .../gitaly/service/operations/branches_test.go | 2 +- .../gitaly/service/operations/cherry_pick_test.go | 2 +- .../gitaly/service/operations/commit_files_test.go | 2 +- internal/gitaly/service/operations/merge_test.go | 2 +- internal/gitaly/service/operations/rebase_test.go | 6 ++-- internal/gitaly/service/operations/revert_test.go | 2 +- internal/gitaly/service/operations/squash_test.go | 2 +- .../gitaly/service/operations/submodules_test.go | 2 +- internal/gitaly/service/operations/tags_test.go | 4 +-- internal/gitaly/service/ref/branches_test.go | 2 +- internal/gitaly/service/ref/delete_refs_test.go | 6 ++-- internal/gitaly/service/ref/find_all_tags_test.go | 4 +-- .../gitaly/service/ref/find_refs_by_oid_test.go | 2 +- internal/gitaly/service/ref/find_tag_test.go | 4 +-- internal/gitaly/service/ref/list_refs_test.go | 2 +- internal/gitaly/service/ref/pack_refs_test.go | 6 ++-- internal/gitaly/service/ref/refexists_test.go | 2 +- internal/gitaly/service/ref/refs_test.go | 32 +++++++++++----------- .../gitaly/service/ref/remote_branches_test.go | 4 +-- internal/gitaly/service/ref/tag_messages_test.go | 2 +- internal/gitaly/service/ref/tag_signatures_test.go | 2 +- .../service/remote/find_remote_root_ref_test.go | 4 +-- .../service/remote/update_remote_mirror_test.go | 2 +- .../service/repository/apply_gitattributes_test.go | 8 +++--- internal/gitaly/service/repository/archive_test.go | 6 ++-- .../service/repository/backup_custom_hooks_test.go | 2 +- .../service/repository/calculate_checksum_test.go | 4 +-- internal/gitaly/service/repository/cleanup_test.go | 6 ++-- .../gitaly/service/repository/commit_graph_test.go | 6 ++-- internal/gitaly/service/repository/config_test.go | 2 +- .../repository/create_bundle_from_ref_list_test.go | 2 +- .../service/repository/create_bundle_test.go | 2 +- .../gitaly/service/repository/create_fork_test.go | 2 +- .../create_repository_from_bundle_test.go | 2 +- .../create_repository_from_snapshot_test.go | 2 +- .../repository/create_repository_from_url_test.go | 2 +- .../service/repository/create_repository_test.go | 6 ++-- .../gitaly/service/repository/fetch_bundle_test.go | 4 +-- internal/gitaly/service/repository/fetch_test.go | 2 +- internal/gitaly/service/repository/fsck_test.go | 2 +- internal/gitaly/service/repository/gc_test.go | 6 ++-- .../service/repository/has_local_branches_test.go | 4 +-- .../service/repository/info_attributes_test.go | 2 +- internal/gitaly/service/repository/license_test.go | 2 +- .../gitaly/service/repository/merge_base_test.go | 2 +- internal/gitaly/service/repository/midx_test.go | 6 ++-- .../gitaly/service/repository/optimize_test.go | 6 ++-- .../gitaly/service/repository/raw_changes_test.go | 2 +- internal/gitaly/service/repository/remove_test.go | 2 +- internal/gitaly/service/repository/rename_test.go | 2 +- internal/gitaly/service/repository/repack_test.go | 16 +++++------ .../gitaly/service/repository/replicate_test.go | 4 +-- .../service/repository/repository_exists_test.go | 6 ++-- .../repository/restore_custom_hooks_test.go | 2 +- internal/gitaly/service/repository/size_test.go | 2 +- internal/gitaly/service/smarthttp/inforefs_test.go | 8 +++--- .../gitaly/service/smarthttp/receive_pack_test.go | 4 +-- .../gitaly/service/smarthttp/upload_pack_test.go | 4 +-- internal/gitaly/service/ssh/upload_archive_test.go | 4 +-- internal/testhelper/testhelper.go | 10 +++---- 94 files changed, 183 insertions(+), 183 deletions(-) diff --git a/internal/gitaly/service/blob/get_blob_test.go b/internal/gitaly/service/blob/get_blob_test.go index e74d76e9b..181cb5b61 100644 --- a/internal/gitaly/service/blob/get_blob_test.go +++ b/internal/gitaly/service/blob/get_blob_test.go @@ -158,7 +158,7 @@ func TestGetBlob_invalidRequest(t *testing.T) { Repository: nil, Oid: oid, }, - expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -172,7 +172,7 @@ func TestGetBlob_invalidRequest(t *testing.T) { }, Oid: oid, }, - expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefect( fmt.Sprintf("create object reader: GetStorageByName: no such storage: %q", "fake"), "repo scoped: invalid Repository", )), @@ -186,7 +186,7 @@ func TestGetBlob_invalidRequest(t *testing.T) { }, Oid: oid, }, - expectedErr: helper.ErrNotFoundf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrNotFoundf(testhelper.GitalyOrPraefect( fmt.Sprintf("create object reader: GetRepoPath: not a git repository: %q", filepath.Join(cfg.Storages[0].Path, "path")), fmt.Sprintf("accessor call: route repository accessor: consistent storages: repository %q/%q not found", cfg.Storages[0].Name, "path"), )), diff --git a/internal/gitaly/service/blob/lfs_pointers_test.go b/internal/gitaly/service/blob/lfs_pointers_test.go index 3455260a0..18edf9746 100644 --- a/internal/gitaly/service/blob/lfs_pointers_test.go +++ b/internal/gitaly/service/blob/lfs_pointers_test.go @@ -298,7 +298,7 @@ size 12345` }) require.NoError(t, err) _, err = stram.Recv() - testhelper.RequireGrpcError(t, status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + testhelper.RequireGrpcError(t, status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), err) diff --git a/internal/gitaly/service/cleanup/apply_bfg_object_map_stream_test.go b/internal/gitaly/service/cleanup/apply_bfg_object_map_stream_test.go index 777bc0897..388c4b973 100644 --- a/internal/gitaly/service/cleanup/apply_bfg_object_map_stream_test.go +++ b/internal/gitaly/service/cleanup/apply_bfg_object_map_stream_test.go @@ -128,7 +128,7 @@ func TestApplyBfgObjectMapStreamFailsOnInvalidInput(t *testing.T) { t.Run("no repository provided", func(t *testing.T) { entries, err := doStreamingRequest(t, ctx, nil, client, objectMapData) require.Empty(t, entries) - testhelper.RequireGrpcError(t, status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + testhelper.RequireGrpcError(t, status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), err) diff --git a/internal/gitaly/service/commit/check_objects_exist_test.go b/internal/gitaly/service/commit/check_objects_exist_test.go index 061c7bc18..dd6fb6320 100644 --- a/internal/gitaly/service/commit/check_objects_exist_test.go +++ b/internal/gitaly/service/commit/check_objects_exist_test.go @@ -43,7 +43,7 @@ func TestCheckObjectsExist(t *testing.T) { { desc: "no repository provided", requests: []*gitalypb.CheckObjectsExistRequest{{Repository: nil}}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/commit/commit_messages_test.go b/internal/gitaly/service/commit/commit_messages_test.go index 0f6cb41ff..c7731707b 100644 --- a/internal/gitaly/service/commit/commit_messages_test.go +++ b/internal/gitaly/service/commit/commit_messages_test.go @@ -75,7 +75,7 @@ func TestFailedGetCommitMessagesRequest(t *testing.T) { Repository: nil, CommitIds: []string{"5937ac0a7beb003549fc5fd26fc247adbce4a52e"}, }, - err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/commit/commit_signatures_test.go b/internal/gitaly/service/commit/commit_signatures_test.go index 463a6d00e..f85a0b1bb 100644 --- a/internal/gitaly/service/commit/commit_signatures_test.go +++ b/internal/gitaly/service/commit/commit_signatures_test.go @@ -103,7 +103,7 @@ func TestFailedGetCommitSignaturesRequest(t *testing.T) { Repository: nil, CommitIds: []string{"5937ac0a7beb003549fc5fd26fc247adbce4a52e"}, }, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "GetCommitSignatures: empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/commit/commits_by_message_test.go b/internal/gitaly/service/commit/commits_by_message_test.go index defbad8b0..1f91de9bb 100644 --- a/internal/gitaly/service/commit/commits_by_message_test.go +++ b/internal/gitaly/service/commit/commits_by_message_test.go @@ -174,7 +174,7 @@ func TestFailedCommitsByMessageRequest(t *testing.T) { { desc: "Invalid repository", request: &gitalypb.CommitsByMessageRequest{Repository: invalidRepo, Query: "foo"}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( `GetStorageByName: no such storage: "fake"`, "repo scoped: invalid Repository", )), @@ -182,7 +182,7 @@ func TestFailedCommitsByMessageRequest(t *testing.T) { { desc: "Repository is nil", request: &gitalypb.CommitsByMessageRequest{Query: "foo"}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/commit/count_commits_test.go b/internal/gitaly/service/commit/count_commits_test.go index 6cee39aff..38a75c5f5 100644 --- a/internal/gitaly/service/commit/count_commits_test.go +++ b/internal/gitaly/service/commit/count_commits_test.go @@ -172,7 +172,7 @@ func TestFailedCountCommitsRequestDueToValidationError(t *testing.T) { { desc: "Repository doesn't exist", req: &gitalypb.CountCommitsRequest{Repository: &gitalypb.Repository{StorageName: "fake", RelativePath: "path"}, Revision: revision}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( `GetStorageByName: no such storage: "fake"`, "repo scoped: invalid Repository", )), @@ -180,7 +180,7 @@ func TestFailedCountCommitsRequestDueToValidationError(t *testing.T) { { desc: "Repository is nil", req: &gitalypb.CountCommitsRequest{Repository: nil, Revision: revision}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "CountCommits: empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/commit/count_diverging_commits_test.go b/internal/gitaly/service/commit/count_diverging_commits_test.go index bf6436e65..40cc81f0e 100644 --- a/internal/gitaly/service/commit/count_diverging_commits_test.go +++ b/internal/gitaly/service/commit/count_diverging_commits_test.go @@ -174,7 +174,7 @@ func TestFailedCountDivergentCommitsRequestDueToValidationError(t *testing.T) { { desc: "Repository not provided", req: &gitalypb.CountDivergingCommitsRequest{Repository: nil, From: []byte("abcdef"), To: []byte("12345")}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -182,7 +182,7 @@ func TestFailedCountDivergentCommitsRequestDueToValidationError(t *testing.T) { { desc: "Repository doesn't exist", req: &gitalypb.CountDivergingCommitsRequest{Repository: &gitalypb.Repository{StorageName: "fake", RelativePath: "path"}, From: []byte("abcdef"), To: []byte("12345")}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( `repository not valid: GetStorageByName: no such storage: "fake"`, "repo scoped: invalid Repository", )), diff --git a/internal/gitaly/service/commit/filter_shas_with_signatures_test.go b/internal/gitaly/service/commit/filter_shas_with_signatures_test.go index 1aa32d577..b50a295ee 100644 --- a/internal/gitaly/service/commit/filter_shas_with_signatures_test.go +++ b/internal/gitaly/service/commit/filter_shas_with_signatures_test.go @@ -74,7 +74,7 @@ func TestFilterShasWithSignaturesValidationError(t *testing.T) { { desc: "no repository provided", req: &gitalypb.FilterShasWithSignaturesRequest{Repository: nil}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/commit/find_all_commits_test.go b/internal/gitaly/service/commit/find_all_commits_test.go index cf45ac9ff..18fdce878 100644 --- a/internal/gitaly/service/commit/find_all_commits_test.go +++ b/internal/gitaly/service/commit/find_all_commits_test.go @@ -176,7 +176,7 @@ func TestFailedFindAllCommitsRequest(t *testing.T) { { desc: "Invalid repository", request: &gitalypb.FindAllCommitsRequest{Repository: invalidRepo}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( `GetStorageByName: no such storage: "fake"`, "repo scoped: invalid Repository", )), @@ -184,7 +184,7 @@ func TestFailedFindAllCommitsRequest(t *testing.T) { { desc: "Repository is nil", request: &gitalypb.FindAllCommitsRequest{}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/commit/find_commit_test.go b/internal/gitaly/service/commit/find_commit_test.go index 38af64d26..cb7c1deee 100644 --- a/internal/gitaly/service/commit/find_commit_test.go +++ b/internal/gitaly/service/commit/find_commit_test.go @@ -255,7 +255,7 @@ func TestFailedFindCommitRequest(t *testing.T) { { desc: "Repository is nil", repo: nil, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -264,7 +264,7 @@ func TestFailedFindCommitRequest(t *testing.T) { desc: "Invalid repo", repo: invalidRepo, revision: []byte("master"), - expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefect( "GetStorageByName: no such storage: \"fake\"", "repo scoped: invalid Repository", )), diff --git a/internal/gitaly/service/commit/find_commits_test.go b/internal/gitaly/service/commit/find_commits_test.go index db698d867..e3521bd83 100644 --- a/internal/gitaly/service/commit/find_commits_test.go +++ b/internal/gitaly/service/commit/find_commits_test.go @@ -526,7 +526,7 @@ func TestFailureFindCommitsRequest(t *testing.T) { Repository: nil, Revision: []byte("HEAD"), }, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/commit/isancestor_test.go b/internal/gitaly/service/commit/isancestor_test.go index 2dec4ada5..90309528d 100644 --- a/internal/gitaly/service/commit/isancestor_test.go +++ b/internal/gitaly/service/commit/isancestor_test.go @@ -33,7 +33,7 @@ func TestCommitIsAncestorFailure(t *testing.T) { AncestorId: "b83d6e391c22777fca1ed3012fce84f633d7fed0", ChildId: "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab", }, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -60,7 +60,7 @@ func TestCommitIsAncestorFailure(t *testing.T) { AncestorId: "b83d6e391c22777fca1ed3012fce84f633d7fed0", ChildId: "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab", }, - expectedErr: status.Error(codes.NotFound, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.NotFound, testhelper.GitalyOrPraefect( `GetRepoPath: not a git repository: "`+cfg.Storages[0].Path+`/fake-path"`, `accessor call: route repository accessor: consistent storages: repository "default"/"fake-path" not found`, )), diff --git a/internal/gitaly/service/commit/languages_test.go b/internal/gitaly/service/commit/languages_test.go index 368af6ec3..90705488c 100644 --- a/internal/gitaly/service/commit/languages_test.go +++ b/internal/gitaly/service/commit/languages_test.go @@ -113,7 +113,7 @@ func TestCommitLanguages_validateRequest(t *testing.T) { { desc: "no repository provided", req: &gitalypb.CommitLanguagesRequest{Repository: nil}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/commit/last_commit_for_path_test.go b/internal/gitaly/service/commit/last_commit_for_path_test.go index 0304088e2..28e19c7d0 100644 --- a/internal/gitaly/service/commit/last_commit_for_path_test.go +++ b/internal/gitaly/service/commit/last_commit_for_path_test.go @@ -92,7 +92,7 @@ func TestFailedLastCommitForPathRequest(t *testing.T) { Repository: invalidRepo, Revision: []byte("some-branch"), }, - expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefect( "GetStorageByName: no such storage: \"fake\"", "repo scoped: invalid Repository", )), @@ -102,7 +102,7 @@ func TestFailedLastCommitForPathRequest(t *testing.T) { request: &gitalypb.LastCommitForPathRequest{ Revision: []byte("some-branch"), }, - expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/commit/list_all_commits_test.go b/internal/gitaly/service/commit/list_all_commits_test.go index fd3e1c02c..a828df9c8 100644 --- a/internal/gitaly/service/commit/list_all_commits_test.go +++ b/internal/gitaly/service/commit/list_all_commits_test.go @@ -153,7 +153,7 @@ func TestListAllCommits_validate(t *testing.T) { req: &gitalypb.ListAllCommitsRequest{ Repository: nil, }, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/commit/list_commits_by_oid_test.go b/internal/gitaly/service/commit/list_commits_by_oid_test.go index a4a5ef290..bb7f64499 100644 --- a/internal/gitaly/service/commit/list_commits_by_oid_test.go +++ b/internal/gitaly/service/commit/list_commits_by_oid_test.go @@ -187,7 +187,7 @@ func TestListCommitsByOid_validate(t *testing.T) { { desc: "repository not provided", req: &gitalypb.ListCommitsByOidRequest{Repository: nil}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/commit/list_commits_by_ref_name_test.go b/internal/gitaly/service/commit/list_commits_by_ref_name_test.go index 5a7cff626..226858b15 100644 --- a/internal/gitaly/service/commit/list_commits_by_ref_name_test.go +++ b/internal/gitaly/service/commit/list_commits_by_ref_name_test.go @@ -207,7 +207,7 @@ func TestListCommitsByRefName_validate(t *testing.T) { { desc: "repository not provided", req: &gitalypb.ListCommitsByRefNameRequest{Repository: nil}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/commit/list_commits_test.go b/internal/gitaly/service/commit/list_commits_test.go index c3b838d26..5a582944e 100644 --- a/internal/gitaly/service/commit/list_commits_test.go +++ b/internal/gitaly/service/commit/list_commits_test.go @@ -330,7 +330,7 @@ func TestListCommits_verify(t *testing.T) { { desc: "no repository provided", req: &gitalypb.ListCommitsRequest{Repository: nil}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/commit/list_files_test.go b/internal/gitaly/service/commit/list_files_test.go index 445f9dfaa..fef0f9e49 100644 --- a/internal/gitaly/service/commit/list_files_test.go +++ b/internal/gitaly/service/commit/list_files_test.go @@ -212,7 +212,7 @@ func TestListFiles_failure(t *testing.T) { { desc: "nil repo", repo: nil, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -220,7 +220,7 @@ func TestListFiles_failure(t *testing.T) { { desc: "empty repo object", repo: &gitalypb.Repository{}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty StorageName", "repo scoped: invalid Repository", )), @@ -228,7 +228,7 @@ func TestListFiles_failure(t *testing.T) { { desc: "non-existing repo", repo: &gitalypb.Repository{StorageName: "foo", RelativePath: "bar"}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( `GetStorageByName: no such storage: "foo"`, "repo scoped: invalid Repository", )), diff --git a/internal/gitaly/service/commit/list_last_commits_for_tree_test.go b/internal/gitaly/service/commit/list_last_commits_for_tree_test.go index b5cc150b1..e60b92096 100644 --- a/internal/gitaly/service/commit/list_last_commits_for_tree_test.go +++ b/internal/gitaly/service/commit/list_last_commits_for_tree_test.go @@ -243,7 +243,7 @@ func TestFailedListLastCommitsForTreeRequest(t *testing.T) { Offset: 0, Limit: 25, }, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( `GetStorageByName: no such storage: "broken"`, "repo scoped: invalid Repository", )), @@ -256,7 +256,7 @@ func TestFailedListLastCommitsForTreeRequest(t *testing.T) { Offset: 0, Limit: 25, }, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/commit/raw_blame_test.go b/internal/gitaly/service/commit/raw_blame_test.go index 39aadc8f4..9d7f3f7c2 100644 --- a/internal/gitaly/service/commit/raw_blame_test.go +++ b/internal/gitaly/service/commit/raw_blame_test.go @@ -92,7 +92,7 @@ func TestFailedRawBlameRequest(t *testing.T) { { description: "No repository provided", repo: nil, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "RawBlame: empty Repository", "repo scoped: empty Repository", )), @@ -103,7 +103,7 @@ func TestFailedRawBlameRequest(t *testing.T) { revision: []byte("master"), path: []byte("a/b/c"), blameRange: []byte{}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( `GetStorageByName: no such storage: "fake"`, "repo scoped: invalid Repository", )), diff --git a/internal/gitaly/service/commit/stats_test.go b/internal/gitaly/service/commit/stats_test.go index b572a1d0b..cce0d5d93 100644 --- a/internal/gitaly/service/commit/stats_test.go +++ b/internal/gitaly/service/commit/stats_test.go @@ -94,7 +94,7 @@ func TestCommitStatsFailure(t *testing.T) { { desc: "no repository provided", request: &gitalypb.CommitStatsRequest{Repository: nil}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -108,7 +108,7 @@ func TestCommitStatsFailure(t *testing.T) { }, Revision: []byte("test-do-not-touch"), }, - expectedErr: helper.ErrNotFoundf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrNotFoundf(testhelper.GitalyOrPraefect( fmt.Sprintf("GetRepoPath: not a git repository: %q", filepath.Join(cfg.Storages[0].Path, "bar.git")), "accessor call: route repository accessor: consistent storages: repository \"default\"/\"bar.git\" not found", )), @@ -122,7 +122,7 @@ func TestCommitStatsFailure(t *testing.T) { }, Revision: []byte("test-do-not-touch"), }, - expectedErr: helper.ErrNotFoundf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrNotFoundf(testhelper.GitalyOrPraefect( fmt.Sprintf("GetRepoPath: not a git repository: %q", filepath.Join(cfg.Storages[0].Path, "bar.git")), "accessor call: route repository accessor: consistent storages: repository \"default\"/\"bar.git\" not found", )), @@ -136,7 +136,7 @@ func TestCommitStatsFailure(t *testing.T) { }, Revision: []byte("test-do-not-touch"), }, - expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefect( "GetStorageByName: no such storage: \"foo\"", "repo scoped: invalid Repository", )), diff --git a/internal/gitaly/service/commit/tree_entries_test.go b/internal/gitaly/service/commit/tree_entries_test.go index 39f97a91a..34d1f9ae7 100644 --- a/internal/gitaly/service/commit/tree_entries_test.go +++ b/internal/gitaly/service/commit/tree_entries_test.go @@ -671,7 +671,7 @@ func TestGetTreeEntries_validation(t *testing.T) { Revision: revision, Path: path, }, - expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefect( "GetStorageByName: no such storage: \"fake\"", "repo scoped: invalid Repository", )), @@ -683,7 +683,7 @@ func TestGetTreeEntries_validation(t *testing.T) { Revision: revision, Path: path, }, - expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefect( "TreeEntry: empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/commit/tree_entry_test.go b/internal/gitaly/service/commit/tree_entry_test.go index 6217720f1..649c09f61 100644 --- a/internal/gitaly/service/commit/tree_entry_test.go +++ b/internal/gitaly/service/commit/tree_entry_test.go @@ -168,7 +168,7 @@ func TestFailedTreeEntry(t *testing.T) { { name: "Repository doesn't exist", req: &gitalypb.TreeEntryRequest{Repository: &gitalypb.Repository{StorageName: "fake", RelativePath: "path"}, Revision: revision, Path: path}, - expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefect( "GetStorageByName: no such storage: \"fake\"", "repo scoped: invalid Repository", )), @@ -176,7 +176,7 @@ func TestFailedTreeEntry(t *testing.T) { { name: "Repository is nil", req: &gitalypb.TreeEntryRequest{Repository: nil, Revision: revision, Path: path}, - expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefect( "TreeEntry: empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/conflicts/list_conflict_files_test.go b/internal/gitaly/service/conflicts/list_conflict_files_test.go index e4eab1d84..a64701786 100644 --- a/internal/gitaly/service/conflicts/list_conflict_files_test.go +++ b/internal/gitaly/service/conflicts/list_conflict_files_test.go @@ -340,7 +340,7 @@ func TestFailedListConflictFilesRequestDueToValidation(t *testing.T) { OurCommitOid: ourCommitOid, TheirCommitOid: theirCommitOid, }, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/conflicts/resolve_conflicts_test.go b/internal/gitaly/service/conflicts/resolve_conflicts_test.go index 7ba39d3e0..611670b6a 100644 --- a/internal/gitaly/service/conflicts/resolve_conflicts_test.go +++ b/internal/gitaly/service/conflicts/resolve_conflicts_test.go @@ -692,7 +692,7 @@ func TestFailedResolveConflictsRequestDueToValidation(t *testing.T) { SourceBranch: sourceBranch, TargetBranch: targetBranch, }, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "ResolveConflicts: empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/diff/commit_test.go b/internal/gitaly/service/diff/commit_test.go index b787de992..18edfa676 100644 --- a/internal/gitaly/service/diff/commit_test.go +++ b/internal/gitaly/service/diff/commit_test.go @@ -805,7 +805,7 @@ func TestFailedCommitDiffRequestDueToValidationError(t *testing.T) { { desc: "Repository doesn't exist", req: &gitalypb.CommitDiffRequest{Repository: &gitalypb.Repository{StorageName: "fake", RelativePath: "path"}, RightCommitId: rightCommit, LeftCommitId: leftCommit}, - exrErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + exrErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( `GetStorageByName: no such storage: "fake"`, "repo scoped: invalid Repository", )), @@ -813,7 +813,7 @@ func TestFailedCommitDiffRequestDueToValidationError(t *testing.T) { { desc: "Repository is nil", req: &gitalypb.CommitDiffRequest{Repository: nil, RightCommitId: rightCommit, LeftCommitId: leftCommit}, - exrErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + exrErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "CommitDiff: empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/diff/find_changed_paths_test.go b/internal/gitaly/service/diff/find_changed_paths_test.go index 9946ed931..f69cc5b4c 100644 --- a/internal/gitaly/service/diff/find_changed_paths_test.go +++ b/internal/gitaly/service/diff/find_changed_paths_test.go @@ -481,7 +481,7 @@ func TestFindChangedPathsRequest_failing(t *testing.T) { desc: "Repository not provided", repo: nil, commits: []string{"e4003da16c1c2c3fc4567700121b17bf8e591c6c", "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab"}, - err: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefectMessage( + err: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -490,7 +490,7 @@ func TestFindChangedPathsRequest_failing(t *testing.T) { desc: "Repo not found", repo: &gitalypb.Repository{StorageName: repo.GetStorageName(), RelativePath: "bar.git"}, commits: []string{"e4003da16c1c2c3fc4567700121b17bf8e591c6c", "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab"}, - err: helper.ErrNotFoundf(testhelper.GitalyOrPraefectMessage( + err: helper.ErrNotFoundf(testhelper.GitalyOrPraefect( fmt.Sprintf("GetRepoPath: not a git repository: %q", filepath.Join(cfg.Storages[0].Path, "bar.git")), `accessor call: route repository accessor: consistent storages: repository "default"/"bar.git" not found`, )), @@ -499,7 +499,7 @@ func TestFindChangedPathsRequest_failing(t *testing.T) { desc: "Storage not found", repo: &gitalypb.Repository{StorageName: "foo", RelativePath: "bar.git"}, commits: []string{"e4003da16c1c2c3fc4567700121b17bf8e591c6c", "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab"}, - err: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefectMessage( + err: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefect( `GetStorageByName: no such storage: "foo"`, "repo scoped: invalid Repository", )), diff --git a/internal/gitaly/service/diff/numstat_test.go b/internal/gitaly/service/diff/numstat_test.go index 82678529e..74764927b 100644 --- a/internal/gitaly/service/diff/numstat_test.go +++ b/internal/gitaly/service/diff/numstat_test.go @@ -134,7 +134,7 @@ func TestFailedDiffStatsRequest(t *testing.T) { repo: nil, leftCommitID: "e4003da16c1c2c3fc4567700121b17bf8e591c6c", rightCommitID: "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab", - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -144,7 +144,7 @@ func TestFailedDiffStatsRequest(t *testing.T) { repo: &gitalypb.Repository{StorageName: repo.GetStorageName(), RelativePath: "bar.git"}, leftCommitID: "e4003da16c1c2c3fc4567700121b17bf8e591c6c", rightCommitID: "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab", - expectedErr: status.Error(codes.NotFound, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.NotFound, testhelper.GitalyOrPraefect( `GetRepoPath: not a git repository: "`+cfg.Storages[0].Path+`/bar.git"`, `accessor call: route repository accessor: consistent storages: repository "default"/"bar.git" not found`, )), @@ -154,7 +154,7 @@ func TestFailedDiffStatsRequest(t *testing.T) { repo: &gitalypb.Repository{StorageName: "foo", RelativePath: "bar.git"}, leftCommitID: "e4003da16c1c2c3fc4567700121b17bf8e591c6c", rightCommitID: "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab", - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( `GetStorageByName: no such storage: "foo"`, "repo scoped: invalid Repository", )), diff --git a/internal/gitaly/service/objectpool/alternates_test.go b/internal/gitaly/service/objectpool/alternates_test.go index 3420f2e10..69b123646 100644 --- a/internal/gitaly/service/objectpool/alternates_test.go +++ b/internal/gitaly/service/objectpool/alternates_test.go @@ -219,7 +219,7 @@ func TestDisconnectGitAlternates_validate(t *testing.T) { { desc: "repository not provided", req: &gitalypb.DisconnectGitAlternatesRequest{Repository: nil}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/objectpool/get_test.go b/internal/gitaly/service/objectpool/get_test.go index bd3125d77..7b22344ca 100644 --- a/internal/gitaly/service/objectpool/get_test.go +++ b/internal/gitaly/service/objectpool/get_test.go @@ -82,7 +82,7 @@ func TestGetObjectPool_validate(t *testing.T) { { desc: "repository not provided", req: &gitalypb.GetObjectPoolRequest{Repository: nil}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/operations/apply_patch_test.go b/internal/gitaly/service/operations/apply_patch_test.go index 9357fe99c..723534687 100644 --- a/internal/gitaly/service/operations/apply_patch_test.go +++ b/internal/gitaly/service/operations/apply_patch_test.go @@ -711,7 +711,7 @@ func TestFailedValidationUserApplyPatch(t *testing.T) { desc: "missing Repository", branchName: "new-branch", user: gittest.TestUser, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/operations/branches_test.go b/internal/gitaly/service/operations/branches_test.go index d366c33c3..f4227a286 100644 --- a/internal/gitaly/service/operations/branches_test.go +++ b/internal/gitaly/service/operations/branches_test.go @@ -355,7 +355,7 @@ func TestUserCreateBranch_Failure(t *testing.T) { branchName: "shiny-new-branch", startPoint: "", user: gittest.TestUser, - err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/operations/cherry_pick_test.go b/internal/gitaly/service/operations/cherry_pick_test.go index 5db8cf075..e45c45836 100644 --- a/internal/gitaly/service/operations/cherry_pick_test.go +++ b/internal/gitaly/service/operations/cherry_pick_test.go @@ -300,7 +300,7 @@ func TestServer_UserCherryPick_failedValidations(t *testing.T) { request: &gitalypb.UserCherryPickRequest{ Repository: nil, }, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/operations/commit_files_test.go b/internal/gitaly/service/operations/commit_files_test.go index 75fe0474a..4d5129c8d 100644 --- a/internal/gitaly/service/operations/commit_files_test.go +++ b/internal/gitaly/service/operations/commit_files_test.go @@ -1485,7 +1485,7 @@ func TestFailedUserCommitFilesRequest(t *testing.T) { { desc: "empty Repository", req: headerRequest(nil, gittest.TestUser, branchName, commitFilesMessage, ""), - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/operations/merge_test.go b/internal/gitaly/service/operations/merge_test.go index 0a6205786..dfbe7e8ff 100644 --- a/internal/gitaly/service/operations/merge_test.go +++ b/internal/gitaly/service/operations/merge_test.go @@ -142,7 +142,7 @@ func TestUserMergeBranch_failure(t *testing.T) { { desc: "no repository provided", repo: nil, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/operations/rebase_test.go b/internal/gitaly/service/operations/rebase_test.go index 80755c81c..1da94bd53 100644 --- a/internal/gitaly/service/operations/rebase_test.go +++ b/internal/gitaly/service/operations/rebase_test.go @@ -785,7 +785,7 @@ func TestUserRebaseConfirmable_failedWithCode(t *testing.T) { buildHeaderRequest: func() *gitalypb.UserRebaseConfirmableRequest { return buildHeaderRequest(nil, gittest.TestUser, "1", rebaseBranchName, branchCommitID, nil, "master") }, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -798,7 +798,7 @@ func TestUserRebaseConfirmable_failedWithCode(t *testing.T) { return buildHeaderRequest(repo, gittest.TestUser, "1", rebaseBranchName, branchCommitID, repo, "master") }, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( `creating repo quarantine: creating object quarantine: getting repo path: GetStorageByName: no such storage: "@this-storage-does-not-exist"`, "repo scoped: invalid Repository", )), @@ -811,7 +811,7 @@ func TestUserRebaseConfirmable_failedWithCode(t *testing.T) { return buildHeaderRequest(repo, gittest.TestUser, "1", rebaseBranchName, branchCommitID, repo, "master") }, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty RelativePath", "repo scoped: invalid Repository", )), diff --git a/internal/gitaly/service/operations/revert_test.go b/internal/gitaly/service/operations/revert_test.go index 067e66f1f..1781bdd80 100644 --- a/internal/gitaly/service/operations/revert_test.go +++ b/internal/gitaly/service/operations/revert_test.go @@ -380,7 +380,7 @@ func TestServer_UserRevert_failuedDueToValidations(t *testing.T) { request: &gitalypb.UserRevertRequest{ Repository: nil, }, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/operations/squash_test.go b/internal/gitaly/service/operations/squash_test.go index 2376fcb9c..f3cd29017 100644 --- a/internal/gitaly/service/operations/squash_test.go +++ b/internal/gitaly/service/operations/squash_test.go @@ -538,7 +538,7 @@ func TestUserSquash_validation(t *testing.T) { StartSha: startSha, EndSha: endSha, }, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/operations/submodules_test.go b/internal/gitaly/service/operations/submodules_test.go index 61528bb14..84f40b943 100644 --- a/internal/gitaly/service/operations/submodules_test.go +++ b/internal/gitaly/service/operations/submodules_test.go @@ -209,7 +209,7 @@ func TestFailedUserUpdateSubmoduleRequestDueToValidations(t *testing.T) { Branch: []byte("some-branch"), CommitMessage: []byte("Update Submodule message"), }, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/operations/tags_test.go b/internal/gitaly/service/operations/tags_test.go index d9006eee8..9ecf3c82b 100644 --- a/internal/gitaly/service/operations/tags_test.go +++ b/internal/gitaly/service/operations/tags_test.go @@ -958,7 +958,7 @@ func TestUserDeleteTag_invalidArgument(t *testing.T) { request: &gitalypb.UserDeleteTagRequest{ Repository: nil, }, - err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -1181,7 +1181,7 @@ func TestUserCreateTag_invalidArgument(t *testing.T) { tagName: "shiny-new-tag", targetRevision: "main", user: gittest.TestUser, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "validating request: empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/ref/branches_test.go b/internal/gitaly/service/ref/branches_test.go index 8e7c50e05..9074b5add 100644 --- a/internal/gitaly/service/ref/branches_test.go +++ b/internal/gitaly/service/ref/branches_test.go @@ -96,7 +96,7 @@ func TestFailedFindBranchRequest(t *testing.T) { { desc: "no repository provided", repo: nil, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/ref/delete_refs_test.go b/internal/gitaly/service/ref/delete_refs_test.go index b26d65ce5..b26e51788 100644 --- a/internal/gitaly/service/ref/delete_refs_test.go +++ b/internal/gitaly/service/ref/delete_refs_test.go @@ -289,7 +289,7 @@ func TestDeleteRefs_validation(t *testing.T) { { desc: "no repository provided", request: &gitalypb.DeleteRefsRequest{Repository: nil}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -300,7 +300,7 @@ func TestDeleteRefs_validation(t *testing.T) { Repository: &gitalypb.Repository{StorageName: "fake", RelativePath: "path"}, ExceptWithPrefix: [][]byte{[]byte("exclude-this")}, }, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( `GetStorageByName: no such storage: "fake"`, "repo scoped: invalid Repository", )), @@ -311,7 +311,7 @@ func TestDeleteRefs_validation(t *testing.T) { Repository: nil, ExceptWithPrefix: [][]byte{[]byte("exclude-this")}, }, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/ref/find_all_tags_test.go b/internal/gitaly/service/ref/find_all_tags_test.go index d81638f00..3cde6d743 100644 --- a/internal/gitaly/service/ref/find_all_tags_test.go +++ b/internal/gitaly/service/ref/find_all_tags_test.go @@ -439,7 +439,7 @@ func TestFindAllTags_invalidRequest(t *testing.T) { { desc: "empty request", request: &gitalypb.FindAllTagsRequest{}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -452,7 +452,7 @@ func TestFindAllTags_invalidRequest(t *testing.T) { RelativePath: "repo", }, }, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( `invalid git directory: GetStorageByName: no such storage: "fake"`, "repo scoped: invalid Repository", )), diff --git a/internal/gitaly/service/ref/find_refs_by_oid_test.go b/internal/gitaly/service/ref/find_refs_by_oid_test.go index ae88fadf5..ec29f71d5 100644 --- a/internal/gitaly/service/ref/find_refs_by_oid_test.go +++ b/internal/gitaly/service/ref/find_refs_by_oid_test.go @@ -228,7 +228,7 @@ func TestFindRefsByOID_validation(t *testing.T) { Repository: nil, Oid: "abcdefg", }, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/ref/find_tag_test.go b/internal/gitaly/service/ref/find_tag_test.go index 74f70bc33..dffcb86b6 100644 --- a/internal/gitaly/service/ref/find_tag_test.go +++ b/internal/gitaly/service/ref/find_tag_test.go @@ -304,7 +304,7 @@ func TestFindTag_invalidRequest(t *testing.T) { { desc: "empty request", request: &gitalypb.FindTagRequest{}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -317,7 +317,7 @@ func TestFindTag_invalidRequest(t *testing.T) { RelativePath: "repo", }, }, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( `invalid git directory: GetStorageByName: no such storage: "fake"`, "repo scoped: invalid Repository", )), diff --git a/internal/gitaly/service/ref/list_refs_test.go b/internal/gitaly/service/ref/list_refs_test.go index 2879ed09b..0a51b3c04 100644 --- a/internal/gitaly/service/ref/list_refs_test.go +++ b/internal/gitaly/service/ref/list_refs_test.go @@ -215,7 +215,7 @@ func TestListRefs_validate(t *testing.T) { { desc: "repository not provided", req: &gitalypb.ListRefsRequest{Repository: nil}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/ref/pack_refs_test.go b/internal/gitaly/service/ref/pack_refs_test.go index d1c879718..2ad2c7adf 100644 --- a/internal/gitaly/service/ref/pack_refs_test.go +++ b/internal/gitaly/service/ref/pack_refs_test.go @@ -82,7 +82,7 @@ func TestPackRefs_invalidRequest(t *testing.T) { { desc: "nil repo", repo: nil, - err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -90,7 +90,7 @@ func TestPackRefs_invalidRequest(t *testing.T) { { desc: "invalid storage name", repo: &gitalypb.Repository{RelativePath: "stub", StorageName: "foo"}, - err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( `GetStorageByName: no such storage: "foo"`, "repo scoped: invalid Repository", )), @@ -100,7 +100,7 @@ func TestPackRefs_invalidRequest(t *testing.T) { repo: &gitalypb.Repository{StorageName: cfg.Storages[0].Name, RelativePath: "bar"}, err: status.Error( codes.NotFound, - testhelper.GitalyOrPraefectMessage( + testhelper.GitalyOrPraefect( fmt.Sprintf(`GetRepoPath: not a git repository: "%s/bar"`, cfg.Storages[0].Path), `routing repository maintenance: getting repository metadata: repository not found`, ), diff --git a/internal/gitaly/service/ref/refexists_test.go b/internal/gitaly/service/ref/refexists_test.go index d56094ba3..7f6579ece 100644 --- a/internal/gitaly/service/ref/refexists_test.go +++ b/internal/gitaly/service/ref/refexists_test.go @@ -76,7 +76,7 @@ func TestRefExists_validate(t *testing.T) { { desc: "repository not provided", req: &gitalypb.RefExistsRequest{Repository: nil}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/ref/refs_test.go b/internal/gitaly/service/ref/refs_test.go index 99146c317..7b437ae76 100644 --- a/internal/gitaly/service/ref/refs_test.go +++ b/internal/gitaly/service/ref/refs_test.go @@ -137,7 +137,7 @@ func TestFindAllBranchNames_validate(t *testing.T) { { desc: "repository not provided", repo: nil, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -145,7 +145,7 @@ func TestFindAllBranchNames_validate(t *testing.T) { { desc: "repository doesn't exist on disk", repo: &gitalypb.Repository{StorageName: cfg.Storages[0].Name, RelativePath: "made/up/path"}, - expectedErr: status.Error(codes.NotFound, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.NotFound, testhelper.GitalyOrPraefect( `GetRepoPath: not a git repository: "`+cfg.Storages[0].Path+`/made/up/path"`, `accessor call: route repository accessor: consistent storages: repository "default"/"made/up/path" not found`, )), @@ -153,7 +153,7 @@ func TestFindAllBranchNames_validate(t *testing.T) { { desc: "unknown storage", repo: &gitalypb.Repository{StorageName: "invalid", RelativePath: repo.GetRelativePath()}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( `GetStorageByName: no such storage: "invalid"`, "repo scoped: invalid Repository", )), @@ -204,7 +204,7 @@ func TestFindAllTagNames_validate(t *testing.T) { { desc: "repository not provided", repo: nil, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -212,7 +212,7 @@ func TestFindAllTagNames_validate(t *testing.T) { { desc: "repository doesn't exist on disk", repo: &gitalypb.Repository{StorageName: cfg.Storages[0].Name, RelativePath: "made/up/path"}, - expectedErr: status.Error(codes.NotFound, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.NotFound, testhelper.GitalyOrPraefect( `GetRepoPath: not a git repository: "`+cfg.Storages[0].Path+`/made/up/path"`, `accessor call: route repository accessor: consistent storages: repository "default"/"made/up/path" not found`, )), @@ -220,7 +220,7 @@ func TestFindAllTagNames_validate(t *testing.T) { { desc: "unknown storage", repo: &gitalypb.Repository{StorageName: "invalid", RelativePath: repo.GetRelativePath()}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( `GetStorageByName: no such storage: "invalid"`, "repo scoped: invalid Repository", )), @@ -282,7 +282,7 @@ func TestFindDefaultBranchName_validate(t *testing.T) { { desc: "repository not provided", repo: nil, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -290,7 +290,7 @@ func TestFindDefaultBranchName_validate(t *testing.T) { { desc: "repository doesn't exist on disk", repo: &gitalypb.Repository{StorageName: cfg.Storages[0].Name, RelativePath: "made/up/path"}, - expectedErr: status.Error(codes.NotFound, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.NotFound, testhelper.GitalyOrPraefect( `GetRepoPath: not a git repository: "`+cfg.Storages[0].Path+`/made/up/path"`, `accessor call: route repository accessor: consistent storages: repository "default"/"made/up/path" not found`, )), @@ -298,7 +298,7 @@ func TestFindDefaultBranchName_validate(t *testing.T) { { desc: "unknown storage", repo: &gitalypb.Repository{StorageName: "invalid", RelativePath: repo.GetRelativePath()}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( `GetStorageByName: no such storage: "invalid"`, "repo scoped: invalid Repository", )), @@ -565,7 +565,7 @@ func TestFindLocalBranches_validate(t *testing.T) { { desc: "repository not provided", repo: nil, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -573,7 +573,7 @@ func TestFindLocalBranches_validate(t *testing.T) { { desc: "repository doesn't exist on disk", repo: &gitalypb.Repository{StorageName: cfg.Storages[0].Name, RelativePath: "made/up/path"}, - expectedErr: status.Error(codes.NotFound, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.NotFound, testhelper.GitalyOrPraefect( `creating object reader: GetRepoPath: not a git repository: "`+cfg.Storages[0].Path+`/made/up/path"`, `accessor call: route repository accessor: consistent storages: repository "default"/"made/up/path" not found`, )), @@ -581,7 +581,7 @@ func TestFindLocalBranches_validate(t *testing.T) { { desc: "unknown storage", repo: &gitalypb.Repository{StorageName: "invalid", RelativePath: repo.GetRelativePath()}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( `creating object reader: GetStorageByName: no such storage: "invalid"`, "repo scoped: invalid Repository", )), @@ -743,7 +743,7 @@ func TestInvalidFindAllBranchesRequest(t *testing.T) { { description: "Empty request", request: &gitalypb.FindAllBranchesRequest{}, - expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -756,7 +756,7 @@ func TestInvalidFindAllBranchesRequest(t *testing.T) { RelativePath: "repo", }, }, - expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefect( "creating object reader: GetStorageByName: no such storage: \"fake\"", "repo scoped: invalid Repository", )), @@ -872,7 +872,7 @@ func TestListTagNamesContainingCommit_validate(t *testing.T) { { desc: "repository not provided", req: &gitalypb.ListTagNamesContainingCommitRequest{Repository: nil}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -990,7 +990,7 @@ func TestListBranchNamesContainingCommit_validate(t *testing.T) { { desc: "repository not provided", req: &gitalypb.ListBranchNamesContainingCommitRequest{Repository: nil}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/ref/remote_branches_test.go b/internal/gitaly/service/ref/remote_branches_test.go index 543264189..e035eb42a 100644 --- a/internal/gitaly/service/ref/remote_branches_test.go +++ b/internal/gitaly/service/ref/remote_branches_test.go @@ -93,7 +93,7 @@ func TestInvalidFindAllRemoteBranchesRequest(t *testing.T) { }, RemoteName: "stub", }, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( `creating object reader: GetStorageByName: no such storage: "fake"`, "repo scoped: invalid Repository", )), @@ -101,7 +101,7 @@ func TestInvalidFindAllRemoteBranchesRequest(t *testing.T) { { description: "Empty repo", request: &gitalypb.FindAllRemoteBranchesRequest{RemoteName: "myRemote"}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/ref/tag_messages_test.go b/internal/gitaly/service/ref/tag_messages_test.go index dfd811853..18c74bc24 100644 --- a/internal/gitaly/service/ref/tag_messages_test.go +++ b/internal/gitaly/service/ref/tag_messages_test.go @@ -67,7 +67,7 @@ func TestFailedGetTagMessagesRequest(t *testing.T) { Repository: nil, TagIds: []string{"5937ac0a7beb003549fc5fd26fc247adbce4a52e"}, }, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/ref/tag_signatures_test.go b/internal/gitaly/service/ref/tag_signatures_test.go index fee224281..0cee821e2 100644 --- a/internal/gitaly/service/ref/tag_signatures_test.go +++ b/internal/gitaly/service/ref/tag_signatures_test.go @@ -194,7 +194,7 @@ func TestGetTagSignatures_validate(t *testing.T) { { desc: "repository not provided", req: &gitalypb.GetTagSignaturesRequest{Repository: nil}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/remote/find_remote_root_ref_test.go b/internal/gitaly/service/remote/find_remote_root_ref_test.go index 0495b95bc..b021e40ad 100644 --- a/internal/gitaly/service/remote/find_remote_root_ref_test.go +++ b/internal/gitaly/service/remote/find_remote_root_ref_test.go @@ -92,7 +92,7 @@ func TestFindRemoteRootRefFailedDueToValidation(t *testing.T) { Repository: &gitalypb.Repository{StorageName: "fake", RelativePath: "path"}, RemoteUrl: "remote-url", }, - expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefect( `GetStorageByName: no such storage: "fake"`, "repo scoped: invalid Repository", )), @@ -102,7 +102,7 @@ func TestFindRemoteRootRefFailedDueToValidation(t *testing.T) { request: &gitalypb.FindRemoteRootRefRequest{ RemoteUrl: "remote-url", }, - expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/remote/update_remote_mirror_test.go b/internal/gitaly/service/remote/update_remote_mirror_test.go index 56bf0c456..8f60ed074 100644 --- a/internal/gitaly/service/remote/update_remote_mirror_test.go +++ b/internal/gitaly/service/remote/update_remote_mirror_test.go @@ -896,7 +896,7 @@ func TestFailedUpdateRemoteMirrorRequestDueToValidation(t *testing.T) { Url: "something", }, }, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/repository/apply_gitattributes_test.go b/internal/gitaly/service/repository/apply_gitattributes_test.go index 6e3f63189..d0bf78f73 100644 --- a/internal/gitaly/service/repository/apply_gitattributes_test.go +++ b/internal/gitaly/service/repository/apply_gitattributes_test.go @@ -229,7 +229,7 @@ func TestApplyGitattributes_failure(t *testing.T) { desc: "no repository provided", repo: nil, revision: nil, - expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -241,7 +241,7 @@ func TestApplyGitattributes_failure(t *testing.T) { StorageName: "foo", }, revision: []byte("master"), - expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefect( `GetStorageByName: no such storage: "foo"`, "repo scoped: invalid Repository", )), @@ -252,7 +252,7 @@ func TestApplyGitattributes_failure(t *testing.T) { RelativePath: repo.GetRelativePath(), }, revision: []byte("master"), - expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefect( "empty StorageName", "repo scoped: invalid Repository", )), @@ -264,7 +264,7 @@ func TestApplyGitattributes_failure(t *testing.T) { RelativePath: "bar", }, revision: []byte("master"), - expectedErr: helper.ErrNotFoundf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrNotFoundf(testhelper.GitalyOrPraefect( `GetRepoPath: not a git repository: "`+cfg.Storages[0].Path+`/bar"`, `mutator call: route repository mutator: get repository id: repository "default"/"bar" not found`, )), diff --git a/internal/gitaly/service/repository/archive_test.go b/internal/gitaly/service/repository/archive_test.go index 5f6d403c0..fa1c1a1aa 100644 --- a/internal/gitaly/service/repository/archive_test.go +++ b/internal/gitaly/service/repository/archive_test.go @@ -304,7 +304,7 @@ func TestGetArchive_inputValidation(t *testing.T) { prefix: "", commitID: commitID, format: gitalypb.GetArchiveRequest_ZIP, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( `GetStorageByName: no such storage: "fake"`, "repo scoped: invalid Repository", )), @@ -315,7 +315,7 @@ func TestGetArchive_inputValidation(t *testing.T) { prefix: "", commitID: commitID, format: gitalypb.GetArchiveRequest_ZIP, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -379,7 +379,7 @@ func TestGetArchive_inputValidation(t *testing.T) { commitID: "sadf", format: gitalypb.GetArchiveRequest_TAR, path: []byte("Here is a string...."), - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty RelativePath", "repo scoped: invalid Repository", )), diff --git a/internal/gitaly/service/repository/backup_custom_hooks_test.go b/internal/gitaly/service/repository/backup_custom_hooks_test.go index eda66c9e0..6aa538790 100644 --- a/internal/gitaly/service/repository/backup_custom_hooks_test.go +++ b/internal/gitaly/service/repository/backup_custom_hooks_test.go @@ -127,7 +127,7 @@ func TestBackupCustomHooks_validate(t *testing.T) { { desc: "repository not provided", req: &gitalypb.BackupCustomHooksRequest{Repository: nil}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/repository/calculate_checksum_test.go b/internal/gitaly/service/repository/calculate_checksum_test.go index 4ff6b5ec0..1679d05c8 100644 --- a/internal/gitaly/service/repository/calculate_checksum_test.go +++ b/internal/gitaly/service/repository/calculate_checksum_test.go @@ -85,7 +85,7 @@ func TestFailedCalculateChecksum(t *testing.T) { { desc: "Invalid repository", request: &gitalypb.CalculateChecksumRequest{Repository: invalidRepo}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( `GetStorageByName: no such storage: "fake"`, "repo scoped: invalid Repository", )), @@ -93,7 +93,7 @@ func TestFailedCalculateChecksum(t *testing.T) { { desc: "Repository is nil", request: &gitalypb.CalculateChecksumRequest{}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/repository/cleanup_test.go b/internal/gitaly/service/repository/cleanup_test.go index 726cc9b6d..d486f8403 100644 --- a/internal/gitaly/service/repository/cleanup_test.go +++ b/internal/gitaly/service/repository/cleanup_test.go @@ -166,7 +166,7 @@ func TestCleanup_invalidRequest(t *testing.T) { }{ { desc: "no repository provided", - err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -174,7 +174,7 @@ func TestCleanup_invalidRequest(t *testing.T) { { desc: "storage doesn't exist", in: &gitalypb.Repository{RelativePath: "stub", StorageName: "stub"}, - err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( `GetStorageByName: no such storage: "stub"`, "repo scoped: invalid Repository", )), @@ -184,7 +184,7 @@ func TestCleanup_invalidRequest(t *testing.T) { in: &gitalypb.Repository{StorageName: cfg.Storages[0].Name, RelativePath: "so/me/some.git"}, err: status.Error( codes.NotFound, - testhelper.GitalyOrPraefectMessage( + testhelper.GitalyOrPraefect( fmt.Sprintf(`GetRepoPath: not a git repository: %q`, filepath.Join(cfg.Storages[0].Path, "so/me/some.git")), `routing repository maintenance: getting repository metadata: repository not found`, ), diff --git a/internal/gitaly/service/repository/commit_graph_test.go b/internal/gitaly/service/repository/commit_graph_test.go index 0f8d33a42..64b0c38af 100644 --- a/internal/gitaly/service/repository/commit_graph_test.go +++ b/internal/gitaly/service/repository/commit_graph_test.go @@ -134,7 +134,7 @@ func TestWriteCommitGraph_validationChecks(t *testing.T) { { desc: "no repository", req: &gitalypb.WriteCommitGraphRequest{}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -142,7 +142,7 @@ func TestWriteCommitGraph_validationChecks(t *testing.T) { { desc: "invalid storage", req: &gitalypb.WriteCommitGraphRequest{Repository: &gitalypb.Repository{RelativePath: "stub", StorageName: "invalid"}}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( `getting commit-graph config: GetStorageByName: no such storage: "invalid"`, "repo scoped: invalid Repository", )), @@ -150,7 +150,7 @@ func TestWriteCommitGraph_validationChecks(t *testing.T) { { desc: "not existing repository", req: &gitalypb.WriteCommitGraphRequest{Repository: &gitalypb.Repository{StorageName: repo.StorageName, RelativePath: "invalid"}}, - expectedErr: status.Error(codes.NotFound, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.NotFound, testhelper.GitalyOrPraefect( fmt.Sprintf(`getting commit-graph config: GetRepoPath: not a git repository: "%s/invalid"`, cfg.Storages[0].Path), "routing repository maintenance: getting repository metadata: repository not found", )), diff --git a/internal/gitaly/service/repository/config_test.go b/internal/gitaly/service/repository/config_test.go index f50b34223..1ae0fa066 100644 --- a/internal/gitaly/service/repository/config_test.go +++ b/internal/gitaly/service/repository/config_test.go @@ -78,7 +78,7 @@ func TestGetConfig(t *testing.T) { t.Run("no repository provided", func(t *testing.T) { _, err := getConfig(t, client, nil) - msg := testhelper.GitalyOrPraefectMessage("empty Repository", "repo scoped: empty Repository") + msg := testhelper.GitalyOrPraefect("empty Repository", "repo scoped: empty Repository") expectedErr := status.Errorf(codes.InvalidArgument, msg) testhelper.RequireGrpcError(t, expectedErr, err) }) diff --git a/internal/gitaly/service/repository/create_bundle_from_ref_list_test.go b/internal/gitaly/service/repository/create_bundle_from_ref_list_test.go index d6e821499..6653ad339 100644 --- a/internal/gitaly/service/repository/create_bundle_from_ref_list_test.go +++ b/internal/gitaly/service/repository/create_bundle_from_ref_list_test.go @@ -124,7 +124,7 @@ func TestCreateBundleFromRefList_validations(t *testing.T) { request: &gitalypb.CreateBundleFromRefListRequest{ Patterns: [][]byte{[]byte("master")}, }, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/repository/create_bundle_test.go b/internal/gitaly/service/repository/create_bundle_test.go index 802e247ac..9cc63d30c 100644 --- a/internal/gitaly/service/repository/create_bundle_test.go +++ b/internal/gitaly/service/repository/create_bundle_test.go @@ -75,7 +75,7 @@ func TestFailedCreateBundleRequestDueToValidations(t *testing.T) { { desc: "empty repository", request: &gitalypb.CreateBundleRequest{}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "CreateBundle: empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/repository/create_fork_test.go b/internal/gitaly/service/repository/create_fork_test.go index cd9fbca89..6e9cf0887 100644 --- a/internal/gitaly/service/repository/create_fork_test.go +++ b/internal/gitaly/service/repository/create_fork_test.go @@ -294,7 +294,7 @@ func TestCreateFork_validate(t *testing.T) { { desc: "repository not provided", req: &gitalypb.CreateForkRequest{Repository: nil, SourceRepository: repo}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "CreateFork: empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/repository/create_repository_from_bundle_test.go b/internal/gitaly/service/repository/create_repository_from_bundle_test.go index 76e8e5b9f..5830c5d00 100644 --- a/internal/gitaly/service/repository/create_repository_from_bundle_test.go +++ b/internal/gitaly/service/repository/create_repository_from_bundle_test.go @@ -253,7 +253,7 @@ func TestCreateRepositoryFromBundle_invalidArgument(t *testing.T) { require.NoError(t, stream.Send(&gitalypb.CreateRepositoryFromBundleRequest{})) _, err = stream.CloseAndRecv() - msg := testhelper.GitalyOrPraefectMessage("CreateRepositoryFromBundle: empty Repository", "repo scoped: empty Repository") + msg := testhelper.GitalyOrPraefect("CreateRepositoryFromBundle: empty Repository", "repo scoped: empty Repository") testhelper.RequireGrpcError(t, err, status.Error(codes.InvalidArgument, msg)) } diff --git a/internal/gitaly/service/repository/create_repository_from_snapshot_test.go b/internal/gitaly/service/repository/create_repository_from_snapshot_test.go index 43bbe2e19..b082a242b 100644 --- a/internal/gitaly/service/repository/create_repository_from_snapshot_test.go +++ b/internal/gitaly/service/repository/create_repository_from_snapshot_test.go @@ -361,7 +361,7 @@ func TestServer_CreateRepositoryFromSnapshot_validate(t *testing.T) { { desc: "no repository provided", req: &gitalypb.CreateRepositoryFromSnapshotRequest{Repository: nil}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/repository/create_repository_from_url_test.go b/internal/gitaly/service/repository/create_repository_from_url_test.go index af04a8c92..0f5687a62 100644 --- a/internal/gitaly/service/repository/create_repository_from_url_test.go +++ b/internal/gitaly/service/repository/create_repository_from_url_test.go @@ -345,7 +345,7 @@ func TestServer_CloneFromURLCommand_validate(t *testing.T) { { desc: "no repository provided", req: &gitalypb.CreateRepositoryFromURLRequest{Repository: nil}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "CreateRepositoryFromURL: empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/repository/create_repository_test.go b/internal/gitaly/service/repository/create_repository_test.go index 7842cb8fb..93bdf6074 100644 --- a/internal/gitaly/service/repository/create_repository_test.go +++ b/internal/gitaly/service/repository/create_repository_test.go @@ -216,7 +216,7 @@ func TestCreateRepository_invalidArguments(t *testing.T) { { desc: "missing repository", repo: nil, - expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -227,7 +227,7 @@ func TestCreateRepository_invalidArguments(t *testing.T) { StorageName: "does not exist", RelativePath: "foobar.git", }, - expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefect( `creating repository: locate repository: GetStorageByName: no such storage: "does not exist"`, "repo scoped: invalid Repository", )), @@ -235,7 +235,7 @@ func TestCreateRepository_invalidArguments(t *testing.T) { { desc: "preexisting repository", repo: preexistingRepo, - expectedErr: helper.ErrAlreadyExistsf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrAlreadyExistsf(testhelper.GitalyOrPraefect( "creating repository: repository exists already", "route repository creation: reserve repository id: repository already exists", )), diff --git a/internal/gitaly/service/repository/fetch_bundle_test.go b/internal/gitaly/service/repository/fetch_bundle_test.go index ba11d469f..d5df87904 100644 --- a/internal/gitaly/service/repository/fetch_bundle_test.go +++ b/internal/gitaly/service/repository/fetch_bundle_test.go @@ -137,7 +137,7 @@ func TestServer_FetchBundle_validation(t *testing.T) { firstRequest: &gitalypb.FetchBundleRequest{ Repository: nil, }, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -150,7 +150,7 @@ func TestServer_FetchBundle_validation(t *testing.T) { RelativePath: "unknown", }, }, - expectedErr: status.Error(codes.NotFound, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.NotFound, testhelper.GitalyOrPraefect( `GetRepoPath: not a git repository: "`+cfg.Storages[0].Path+`/unknown"`, `mutator call: route repository mutator: get repository id: repository "default"/"unknown" not found`, )), diff --git a/internal/gitaly/service/repository/fetch_test.go b/internal/gitaly/service/repository/fetch_test.go index a368543b8..acefd9547 100644 --- a/internal/gitaly/service/repository/fetch_test.go +++ b/internal/gitaly/service/repository/fetch_test.go @@ -156,7 +156,7 @@ func TestFetchSourceBranch_validate(t *testing.T) { { desc: "no repository provided", req: &gitalypb.FetchSourceBranchRequest{Repository: nil}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/repository/fsck_test.go b/internal/gitaly/service/repository/fsck_test.go index 077e560bf..8fddbb1f5 100644 --- a/internal/gitaly/service/repository/fsck_test.go +++ b/internal/gitaly/service/repository/fsck_test.go @@ -71,6 +71,6 @@ func TestFsck_validate(t *testing.T) { _, client := setupRepositoryServiceWithoutRepo(t) _, err := client.Fsck(ctx, &gitalypb.FsckRequest{Repository: nil}) - msg := testhelper.GitalyOrPraefectMessage("empty Repository", "repo scoped: empty Repository") + msg := testhelper.GitalyOrPraefect("empty Repository", "repo scoped: empty Repository") testhelper.RequireGrpcError(t, status.Error(codes.InvalidArgument, msg), err) } diff --git a/internal/gitaly/service/repository/gc_test.go b/internal/gitaly/service/repository/gc_test.go index 7d3b9b05d..fafe3a212 100644 --- a/internal/gitaly/service/repository/gc_test.go +++ b/internal/gitaly/service/repository/gc_test.go @@ -409,14 +409,14 @@ func TestGarbageCollectFailure(t *testing.T) { }{ { repo: nil, - err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), }, { repo: &gitalypb.Repository{RelativePath: "stub", StorageName: "foo"}, - err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( `GetStorageByName: no such storage: "foo"`, "repo scoped: invalid Repository", )), @@ -425,7 +425,7 @@ func TestGarbageCollectFailure(t *testing.T) { repo: &gitalypb.Repository{StorageName: repo.StorageName, RelativePath: "bar"}, err: status.Error( codes.NotFound, - testhelper.GitalyOrPraefectMessage( + testhelper.GitalyOrPraefect( fmt.Sprintf(`GetRepoPath: not a git repository: "%s/bar"`, storagePath), `routing repository maintenance: getting repository metadata: repository not found`, ), diff --git a/internal/gitaly/service/repository/has_local_branches_test.go b/internal/gitaly/service/repository/has_local_branches_test.go index 976636b44..4c53a77e8 100644 --- a/internal/gitaly/service/repository/has_local_branches_test.go +++ b/internal/gitaly/service/repository/has_local_branches_test.go @@ -67,7 +67,7 @@ func TestHasLocalBranches_failure(t *testing.T) { { desc: "repository nil", repository: nil, - expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -78,7 +78,7 @@ func TestHasLocalBranches_failure(t *testing.T) { StorageName: "fake", RelativePath: "path", }, - expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefect( `GetStorageByName: no such storage: "fake"`, "repo scoped: invalid Repository", )), diff --git a/internal/gitaly/service/repository/info_attributes_test.go b/internal/gitaly/service/repository/info_attributes_test.go index 74b9a3be0..eb1f2ea06 100644 --- a/internal/gitaly/service/repository/info_attributes_test.go +++ b/internal/gitaly/service/repository/info_attributes_test.go @@ -70,6 +70,6 @@ func TestGetInfoAttributes_validate(t *testing.T) { response, err := client.GetInfoAttributes(ctx, &gitalypb.GetInfoAttributesRequest{Repository: nil}) require.NoError(t, err) _, err = response.Recv() - msg := testhelper.GitalyOrPraefectMessage("empty Repository", "repo scoped: empty Repository") + msg := testhelper.GitalyOrPraefect("empty Repository", "repo scoped: empty Repository") testhelper.RequireGrpcError(t, status.Error(codes.InvalidArgument, msg), err) } diff --git a/internal/gitaly/service/repository/license_test.go b/internal/gitaly/service/repository/license_test.go index 5f9532474..fbbd36a79 100644 --- a/internal/gitaly/service/repository/license_test.go +++ b/internal/gitaly/service/repository/license_test.go @@ -278,7 +278,7 @@ func TestFindLicense_validate(t *testing.T) { client, serverSocketPath := runRepositoryService(t, cfg, nil) cfg.SocketPath = serverSocketPath _, err := client.FindLicense(ctx, &gitalypb.FindLicenseRequest{Repository: nil}) - msg := testhelper.GitalyOrPraefectMessage("empty Repository", "repo scoped: empty Repository") + msg := testhelper.GitalyOrPraefect("empty Repository", "repo scoped: empty Repository") testhelper.RequireGrpcError(t, status.Error(codes.InvalidArgument, msg), err) } diff --git a/internal/gitaly/service/repository/merge_base_test.go b/internal/gitaly/service/repository/merge_base_test.go index e25ad3827..43f26b956 100644 --- a/internal/gitaly/service/repository/merge_base_test.go +++ b/internal/gitaly/service/repository/merge_base_test.go @@ -93,7 +93,7 @@ func TestFailedFindMergeBaseRequestDueToValidations(t *testing.T) { { desc: "no repository provided", req: &gitalypb.FindMergeBaseRequest{Repository: nil}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/repository/midx_test.go b/internal/gitaly/service/repository/midx_test.go index 92029d04f..03769bf99 100644 --- a/internal/gitaly/service/repository/midx_test.go +++ b/internal/gitaly/service/repository/midx_test.go @@ -295,7 +295,7 @@ func TestMidxRepack_validationChecks(t *testing.T) { { desc: "no repository", req: &gitalypb.MidxRepackRequest{}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -303,7 +303,7 @@ func TestMidxRepack_validationChecks(t *testing.T) { { desc: "invalid storage", req: &gitalypb.MidxRepackRequest{Repository: &gitalypb.Repository{RelativePath: "stub", StorageName: "invalid"}}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( `GetStorageByName: no such storage: "invalid"`, "repo scoped: invalid Repository", )), @@ -311,7 +311,7 @@ func TestMidxRepack_validationChecks(t *testing.T) { { desc: "not existing repository", req: &gitalypb.MidxRepackRequest{Repository: &gitalypb.Repository{StorageName: cfg.Storages[0].Name, RelativePath: "invalid"}}, - expectedErr: status.Error(codes.NotFound, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.NotFound, testhelper.GitalyOrPraefect( fmt.Sprintf(`GetRepoPath: not a git repository: "%s/invalid"`, cfg.Storages[0].Path), "routing repository maintenance: getting repository metadata: repository not found", )), diff --git a/internal/gitaly/service/repository/optimize_test.go b/internal/gitaly/service/repository/optimize_test.go index a337e0418..8f0f667f9 100644 --- a/internal/gitaly/service/repository/optimize_test.go +++ b/internal/gitaly/service/repository/optimize_test.go @@ -298,7 +298,7 @@ func TestOptimizeRepository_validation(t *testing.T) { { desc: "empty repository", request: &gitalypb.OptimizeRepositoryRequest{}, - expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -311,7 +311,7 @@ func TestOptimizeRepository_validation(t *testing.T) { RelativePath: repo.GetRelativePath(), }, }, - expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefect( `GetStorageByName: no such storage: "non-existent"`, "repo scoped: invalid Repository"), ), @@ -324,7 +324,7 @@ func TestOptimizeRepository_validation(t *testing.T) { RelativePath: "path/not/exist", }, }, - expectedErr: helper.ErrNotFoundf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrNotFoundf(testhelper.GitalyOrPraefect( fmt.Sprintf(`GetRepoPath: not a git repository: "%s/path/not/exist"`, cfg.Storages[0].Path), `routing repository maintenance: getting repository metadata: repository not found`, )), diff --git a/internal/gitaly/service/repository/raw_changes_test.go b/internal/gitaly/service/repository/raw_changes_test.go index da1c3fdf2..5079243c3 100644 --- a/internal/gitaly/service/repository/raw_changes_test.go +++ b/internal/gitaly/service/repository/raw_changes_test.go @@ -184,7 +184,7 @@ func TestGetRawChangesFailures(t *testing.T) { FromRevision: "cfe32cf61b73a0d5e9f13e774abde7ff789b1660", ToRevision: "913c66a37b4a45b9769037c55c2d238bd0942d2e", }, - expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefectMessage( + expectedErr: helper.ErrInvalidArgumentf(testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/repository/remove_test.go b/internal/gitaly/service/repository/remove_test.go index 2fac149eb..6a83fd588 100644 --- a/internal/gitaly/service/repository/remove_test.go +++ b/internal/gitaly/service/repository/remove_test.go @@ -56,7 +56,7 @@ func TestRemoveRepository_validate(t *testing.T) { ctx := testhelper.Context(t) _, client := setupRepositoryServiceWithoutRepo(t) _, err := client.RemoveRepository(ctx, &gitalypb.RemoveRepositoryRequest{Repository: nil}) - testhelper.RequireGrpcError(t, status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + testhelper.RequireGrpcError(t, status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "missing repository", )), err) diff --git a/internal/gitaly/service/repository/rename_test.go b/internal/gitaly/service/repository/rename_test.go index 3327f6e6c..9f9b7afff 100644 --- a/internal/gitaly/service/repository/rename_test.go +++ b/internal/gitaly/service/repository/rename_test.go @@ -123,7 +123,7 @@ func TestRenameRepositoryInvalidRequest(t *testing.T) { { desc: "repository relative path doesn't exist", req: &gitalypb.RenameRepositoryRequest{Repository: &gitalypb.Repository{StorageName: repo.StorageName, RelativePath: "stub"}, RelativePath: "non-existent/directory"}, - exp: status.Error(codes.NotFound, fmt.Sprintf(`GetRepoPath: not a git repository: "%s/stub"`, testhelper.GitalyOrPraefectMessage(storagePath, repo.GetStorageName()))), + exp: status.Error(codes.NotFound, fmt.Sprintf(`GetRepoPath: not a git repository: "%s/stub"`, testhelper.GitalyOrPraefect(storagePath, repo.GetStorageName()))), }, } diff --git a/internal/gitaly/service/repository/repack_test.go b/internal/gitaly/service/repository/repack_test.go index ecca82f15..d4a6692f7 100644 --- a/internal/gitaly/service/repository/repack_test.go +++ b/internal/gitaly/service/repository/repack_test.go @@ -114,7 +114,7 @@ func TestRepackIncrementalFailure(t *testing.T) { { desc: "nil repo", repo: nil, - err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -122,7 +122,7 @@ func TestRepackIncrementalFailure(t *testing.T) { { desc: "invalid storage name", repo: &gitalypb.Repository{RelativePath: "stub", StorageName: "foo"}, - err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( `repacking objects: GetStorageByName: no such storage: "foo"`, "repo scoped: invalid Repository", )), @@ -130,7 +130,7 @@ func TestRepackIncrementalFailure(t *testing.T) { { desc: "no storage name", repo: &gitalypb.Repository{RelativePath: "bar"}, - err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty StorageName", "repo scoped: invalid Repository", )), @@ -140,7 +140,7 @@ func TestRepackIncrementalFailure(t *testing.T) { repo: &gitalypb.Repository{StorageName: cfg.Storages[0].Name, RelativePath: "bar"}, err: status.Error( codes.NotFound, - testhelper.GitalyOrPraefectMessage( + testhelper.GitalyOrPraefect( fmt.Sprintf(`repacking objects: GetRepoPath: not a git repository: "%s/bar"`, cfg.Storages[0].Path), praefectErr, ), @@ -264,24 +264,24 @@ func TestRepackFullFailure(t *testing.T) { { desc: "nil repo", repo: nil, - err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage("empty Repository", "repo scoped: empty Repository")), + err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect("empty Repository", "repo scoped: empty Repository")), }, { desc: "invalid storage name", repo: &gitalypb.Repository{RelativePath: "stub", StorageName: "foo"}, - err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage(`repacking objects: GetStorageByName: no such storage: "foo"`, "repo scoped: invalid Repository")), + err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect(`repacking objects: GetStorageByName: no such storage: "foo"`, "repo scoped: invalid Repository")), }, { desc: "no storage name", repo: &gitalypb.Repository{RelativePath: "bar"}, - err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage("empty StorageName", "repo scoped: invalid Repository")), + err: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect("empty StorageName", "repo scoped: invalid Repository")), }, { desc: "non-existing repo", repo: &gitalypb.Repository{StorageName: cfg.Storages[0].Name, RelativePath: "bar"}, err: status.Error( codes.NotFound, - testhelper.GitalyOrPraefectMessage( + testhelper.GitalyOrPraefect( fmt.Sprintf(`repacking objects: GetRepoPath: not a git repository: "%s/bar"`, cfg.Storages[0].Path), praefectErr, ), diff --git a/internal/gitaly/service/repository/replicate_test.go b/internal/gitaly/service/repository/replicate_test.go index 734367221..209aef7be 100644 --- a/internal/gitaly/service/repository/replicate_test.go +++ b/internal/gitaly/service/repository/replicate_test.go @@ -337,7 +337,7 @@ func TestReplicateRepositoryInvalidArguments(t *testing.T) { }, Source: nil, }, - expectedError: testhelper.GitalyOrPraefectMessage( + expectedError: testhelper.GitalyOrPraefect( "source repository cannot be empty", "repo scoped: invalid Repository", ), @@ -354,7 +354,7 @@ func TestReplicateRepositoryInvalidArguments(t *testing.T) { RelativePath: "/ab/cd/abcdef1234", }, }, - expectedError: testhelper.GitalyOrPraefectMessage( + expectedError: testhelper.GitalyOrPraefect( "repository and source have the same storage", "repo scoped: invalid Repository", ), diff --git a/internal/gitaly/service/repository/repository_exists_test.go b/internal/gitaly/service/repository/repository_exists_test.go index 0f1421177..6ebc9e04e 100644 --- a/internal/gitaly/service/repository/repository_exists_test.go +++ b/internal/gitaly/service/repository/repository_exists_test.go @@ -41,7 +41,7 @@ func TestRepositoryExists(t *testing.T) { request: &gitalypb.RepositoryExistsRequest{ Repository: nil, }, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage(gitalyerrors.ErrEmptyRepository.Error(), "missing repository")), + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect(gitalyerrors.ErrEmptyRepository.Error(), "missing repository")), }, { desc: "storage name empty", @@ -51,7 +51,7 @@ func TestRepositoryExists(t *testing.T) { RelativePath: repo.GetRelativePath(), }, }, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage(gitalyerrors.ErrEmptyStorageName.Error(), "repository missing storage name")), + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect(gitalyerrors.ErrEmptyStorageName.Error(), "repository missing storage name")), }, { desc: "relative path empty", @@ -61,7 +61,7 @@ func TestRepositoryExists(t *testing.T) { RelativePath: "", }, }, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage(gitalyerrors.ErrEmptyRelativePath.Error(), "repository missing relative path")), + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect(gitalyerrors.ErrEmptyRelativePath.Error(), "repository missing relative path")), }, { desc: "exists true", diff --git a/internal/gitaly/service/repository/restore_custom_hooks_test.go b/internal/gitaly/service/repository/restore_custom_hooks_test.go index 35eb25e55..0b5257dd7 100644 --- a/internal/gitaly/service/repository/restore_custom_hooks_test.go +++ b/internal/gitaly/service/repository/restore_custom_hooks_test.go @@ -109,7 +109,7 @@ func testFailedRestoreCustomHooksDueToValidations(t *testing.T, ctx context.Cont require.NoError(t, stream.Send(&gitalypb.RestoreCustomHooksRequest{})) _, err = stream.CloseAndRecv() - testhelper.RequireGrpcError(t, err, status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + testhelper.RequireGrpcError(t, err, status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "RestoreCustomHooks: empty Repository", "repo scoped: empty Repository", ))) diff --git a/internal/gitaly/service/repository/size_test.go b/internal/gitaly/service/repository/size_test.go index 2f4d24a6e..45c51bb99 100644 --- a/internal/gitaly/service/repository/size_test.go +++ b/internal/gitaly/service/repository/size_test.go @@ -218,7 +218,7 @@ func testFailedRepositorySizeRequest(t *testing.T, ctx context.Context) { { description: "no repository provided", repo: nil, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/smarthttp/inforefs_test.go b/internal/gitaly/service/smarthttp/inforefs_test.go index f4242428a..9574bb65a 100644 --- a/internal/gitaly/service/smarthttp/inforefs_test.go +++ b/internal/gitaly/service/smarthttp/inforefs_test.go @@ -144,7 +144,7 @@ func TestInfoRefsUploadPack_validate(t *testing.T) { { desc: "repository not provided", req: &gitalypb.InfoRefsRequest{Repository: nil}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -155,7 +155,7 @@ func TestInfoRefsUploadPack_validate(t *testing.T) { StorageName: cfg.Storages[0].Name, RelativePath: "doesnt/exist", }}, - expectedErr: status.Error(codes.NotFound, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.NotFound, testhelper.GitalyOrPraefect( `GetRepoPath: not a git repository: "`+cfg.Storages[0].Path+`/doesnt/exist"`, `accessor call: route repository accessor: consistent storages: repository "default"/"doesnt/exist" not found`, )), @@ -357,7 +357,7 @@ func TestInfoRefsReceivePack_validate(t *testing.T) { { desc: "repository not provided", req: &gitalypb.InfoRefsRequest{Repository: nil}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), @@ -368,7 +368,7 @@ func TestInfoRefsReceivePack_validate(t *testing.T) { StorageName: cfg.Storages[0].Name, RelativePath: "testdata/scratch/another_repo", }}, - expectedErr: status.Error(codes.NotFound, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.NotFound, testhelper.GitalyOrPraefect( `GetRepoPath: not a git repository: "`+cfg.Storages[0].Path+`/testdata/scratch/another_repo"`, `accessor call: route repository accessor: consistent storages: repository "default"/"testdata/scratch/another_repo" not found`, )), diff --git a/internal/gitaly/service/smarthttp/receive_pack_test.go b/internal/gitaly/service/smarthttp/receive_pack_test.go index 5059e4c7c..d7b066969 100644 --- a/internal/gitaly/service/smarthttp/receive_pack_test.go +++ b/internal/gitaly/service/smarthttp/receive_pack_test.go @@ -378,7 +378,7 @@ func TestPostReceivePack_requestValidation(t *testing.T) { }, GlId: "user-123", }, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( `GetStorageByName: no such storage: "fake"`, "repo scoped: invalid Repository", )), @@ -386,7 +386,7 @@ func TestPostReceivePack_requestValidation(t *testing.T) { { desc: "Repository is nil", request: &gitalypb.PostReceivePackRequest{Repository: nil, GlId: "user-123"}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/smarthttp/upload_pack_test.go b/internal/gitaly/service/smarthttp/upload_pack_test.go index 84aa96332..398a5df8c 100644 --- a/internal/gitaly/service/smarthttp/upload_pack_test.go +++ b/internal/gitaly/service/smarthttp/upload_pack_test.go @@ -386,7 +386,7 @@ func testServerPostUploadPackWithSideChannelValidation(t *testing.T, ctx context { desc: "Repository doesn't exist", req: &gitalypb.PostUploadPackRequest{Repository: &gitalypb.Repository{StorageName: "fake", RelativePath: "path"}}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( `GetStorageByName: no such storage: "fake"`, "repo scoped: invalid Repository", )), @@ -394,7 +394,7 @@ func testServerPostUploadPackWithSideChannelValidation(t *testing.T, ctx context { desc: "Repository no provided", req: &gitalypb.PostUploadPackRequest{Repository: nil}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/gitaly/service/ssh/upload_archive_test.go b/internal/gitaly/service/ssh/upload_archive_test.go index fff78644a..9e00db031 100644 --- a/internal/gitaly/service/ssh/upload_archive_test.go +++ b/internal/gitaly/service/ssh/upload_archive_test.go @@ -74,7 +74,7 @@ func TestFailedUploadArchiveRequestDueToValidationError(t *testing.T) { { Desc: "Repository.RelativePath is empty", Req: &gitalypb.SSHUploadArchiveRequest{Repository: &gitalypb.Repository{StorageName: cfg.Storages[0].Name, RelativePath: ""}}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty RelativePath", "repo scoped: invalid Repository", )), @@ -82,7 +82,7 @@ func TestFailedUploadArchiveRequestDueToValidationError(t *testing.T) { { Desc: "Repository is nil", Req: &gitalypb.SSHUploadArchiveRequest{Repository: nil}, - expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefectMessage( + expectedErr: status.Error(codes.InvalidArgument, testhelper.GitalyOrPraefect( "empty Repository", "repo scoped: empty Repository", )), diff --git a/internal/testhelper/testhelper.go b/internal/testhelper/testhelper.go index e67327695..20b6cbcdb 100644 --- a/internal/testhelper/testhelper.go +++ b/internal/testhelper/testhelper.go @@ -375,11 +375,11 @@ func GenerateCerts(tb testing.TB) (string, string) { return certFile.Name(), keyFile.Name() } -// GitalyOrPraefectMessage returns gitalyMsg if GITALY_TEST_WITH_PRAEFECT env var is not set and -// praefectMsg otherwise. -func GitalyOrPraefectMessage(gitalyMsg, praefectMsg string) string { +// GitalyOrPraefect returns either the Gitaly- or Praefect-specific object depending on whether +// tests are running with Praefect as a proxy or not. +func GitalyOrPraefect[Type any](gitaly, praefect Type) Type { if IsPraefectEnabled() { - return praefectMsg + return praefect } - return gitalyMsg + return gitaly } -- cgit v1.2.3