diff --git a/internal/helper/repo_test.go b/internal/helper/repo_test.go index 5bb307b2e6a618f3cb647d731fc90cbc7946dd96..53188000edba5adaf8ae3a607a0fc67dd9153700 100644 --- a/internal/helper/repo_test.go +++ b/internal/helper/repo_test.go @@ -126,7 +126,7 @@ func TestGetRepoPath(t *testing.T) { path, err := GetRepoPath(tc.repo) if tc.err != codes.OK { - testhelper.AssertGrpcError(t, err, tc.err, "") + testhelper.RequireGrpcError(t, err, tc.err) return } @@ -150,7 +150,7 @@ func assertInvalidRepoWithoutFile(t *testing.T, repo *pb.Repository, repoPath, f _, err := GetRepoPath(repo) - testhelper.AssertGrpcError(t, err, codes.NotFound, "") + testhelper.RequireGrpcError(t, err, codes.NotFound) } func TestGetRepoPathWithCorruptedRepo(t *testing.T) { diff --git a/internal/rubyserver/rubyserver_test.go b/internal/rubyserver/rubyserver_test.go index 5233d720cb117bcfdcfd0949d5db1de7c8ef81c9..bc0d100b5466ec583202f7cd6f9ef8b30d9ffbe0 100644 --- a/internal/rubyserver/rubyserver_test.go +++ b/internal/rubyserver/rubyserver_test.go @@ -76,7 +76,7 @@ func TestSetHeaders(t *testing.T) { clientCtx, err := tc.setter(ctx, tc.repo) if tc.errType != codes.OK { - testhelper.AssertGrpcError(t, err, tc.errType, "") + testhelper.RequireGrpcError(t, err, tc.errType) assert.Nil(t, clientCtx) } else { assert.NoError(t, err) diff --git a/internal/server/auth_test.go b/internal/server/auth_test.go index 968a01144485b02629077c1b9071a1005f247266..f2ca591b98170829a47b22da099ee514c895ac34 100644 --- a/internal/server/auth_test.go +++ b/internal/server/auth_test.go @@ -63,7 +63,7 @@ func TestAuthFailures(t *testing.T) { conn, err := dial(serverSocketPath, connOpts) require.NoError(t, err, tc.desc) defer conn.Close() - testhelper.AssertGrpcError(t, healthCheck(conn), tc.code, "") + testhelper.RequireGrpcError(t, healthCheck(conn), tc.code) }) } } diff --git a/internal/service/blob/get_blobs_test.go b/internal/service/blob/get_blobs_test.go index 6eb3bd26ce39d52febb1fdc911917a3edacbf932..c678b3ab690dd0adc084d20a2d677a2599d78b6a 100644 --- a/internal/service/blob/get_blobs_test.go +++ b/internal/service/blob/get_blobs_test.go @@ -165,7 +165,7 @@ func TestFailedGetBlobsRequestDueToValidation(t *testing.T) { _, err = stream.Recv() require.NotEqual(t, io.EOF, err) - testhelper.AssertGrpcError(t, err, testCase.code, "") + testhelper.RequireGrpcError(t, err, testCase.code) }) } } diff --git a/internal/service/blob/lfs_pointers_test.go b/internal/service/blob/lfs_pointers_test.go index cd76e2d2cc984e19263e52e70f06d3c0a3919bef..d4fec0348d120418ba7d550f500cd62481cb73cc 100644 --- a/internal/service/blob/lfs_pointers_test.go +++ b/internal/service/blob/lfs_pointers_test.go @@ -119,7 +119,7 @@ func TestFailedGetLFSPointersRequestDueToValidations(t *testing.T) { _, err = stream.Recv() require.NotEqual(t, io.EOF, err) - testhelper.AssertGrpcError(t, err, testCase.code, "") + testhelper.RequireGrpcError(t, err, testCase.code) }) } } @@ -304,7 +304,7 @@ func TestFailedGetNewLFSPointersRequestDueToValidations(t *testing.T) { require.NoError(t, err) err = drainNewPointers(c) - testhelper.AssertGrpcError(t, err, codes.InvalidArgument, tc.desc) + testhelper.RequireGrpcError(t, err, codes.InvalidArgument) }) } } @@ -420,7 +420,7 @@ func TestFailedGetAllLFSPointersRequestDueToValidations(t *testing.T) { require.NoError(t, err) err = drainAllPointers(c) - testhelper.AssertGrpcError(t, err, codes.InvalidArgument, tc.desc) + testhelper.RequireGrpcError(t, err, codes.InvalidArgument) }) } } diff --git a/internal/service/commit/between_test.go b/internal/service/commit/between_test.go index c9eb46f6a4481f799b8d50e1176d2b31866c352f..8ebe09b4d09d8c23ac11064f8f94984f8abd7464 100644 --- a/internal/service/commit/between_test.go +++ b/internal/service/commit/between_test.go @@ -267,7 +267,7 @@ func TestFailedCommitsBetweenRequest(t *testing.T) { } err = drainCommitsBetweenResponse(c) - testhelper.AssertGrpcError(t, err, tc.code, "") + testhelper.RequireGrpcError(t, err, tc.code) }) } } diff --git a/internal/service/commit/commit_messages_test.go b/internal/service/commit/commit_messages_test.go index 33a221e58881db64721a8bdde6c89cb0412bcd54..a9ce8b4b1e19a6ec7bbbc5d5d8df24a64253603b 100644 --- a/internal/service/commit/commit_messages_test.go +++ b/internal/service/commit/commit_messages_test.go @@ -93,7 +93,7 @@ func TestFailedGetCommitMessagesRequest(t *testing.T) { } } - testhelper.AssertGrpcError(t, err, testCase.code, "") + testhelper.RequireGrpcError(t, err, testCase.code) }) } } diff --git a/internal/service/commit/commit_signatures_test.go b/internal/service/commit/commit_signatures_test.go index 79f7b2d1cbce96e2fc908f8d10201f95aded7f52..026bbd3b65175c82ac54b65f307a668139d467fc 100644 --- a/internal/service/commit/commit_signatures_test.go +++ b/internal/service/commit/commit_signatures_test.go @@ -103,7 +103,7 @@ func TestFailedGetCommitSignaturesRequest(t *testing.T) { } } - testhelper.AssertGrpcError(t, err, testCase.code, "") + testhelper.RequireGrpcError(t, err, testCase.code) }) } } diff --git a/internal/service/commit/commits_by_message_test.go b/internal/service/commit/commits_by_message_test.go index f2990b47ec3d6c9c31e60c1a2c1155e6301be957..5f62a6cec93f4803e8bccdcca23081038088cff1 100644 --- a/internal/service/commit/commits_by_message_test.go +++ b/internal/service/commit/commits_by_message_test.go @@ -198,7 +198,7 @@ func TestFailedCommitsByMessageRequest(t *testing.T) { t.Fatal(err) } - testhelper.AssertGrpcError(t, drainCommitsByMessageResponse(c), testCase.code, "") + testhelper.RequireGrpcError(t, drainCommitsByMessageResponse(c), testCase.code) }) } } diff --git a/internal/service/commit/count_commits_test.go b/internal/service/commit/count_commits_test.go index 64a4b40c18f1fd35eb66dd0d11a89ebc9e7d66fd..33ae04c22fe041508150c237669016b2821c60ea 100644 --- a/internal/service/commit/count_commits_test.go +++ b/internal/service/commit/count_commits_test.go @@ -189,7 +189,7 @@ func TestFailedCountCommitsRequestDueToValidationError(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() _, err := client.CountCommits(ctx, &rpcRequest) - testhelper.AssertGrpcError(t, err, codes.InvalidArgument, "") + testhelper.RequireGrpcError(t, err, codes.InvalidArgument) }) } } diff --git a/internal/service/commit/extractsignature_test.go b/internal/service/commit/extractsignature_test.go index 3620cce6795cfbdfae17fe412e726acac6b63056..81b4644566cd35e77edb5537a65f496111aa71e2 100644 --- a/internal/service/commit/extractsignature_test.go +++ b/internal/service/commit/extractsignature_test.go @@ -158,7 +158,7 @@ func TestExtractCommitSignatureFail(t *testing.T) { if tc.code == codes.OK { require.Equal(t, io.EOF, err, "expect EOF when there is no error") } else { - testhelper.AssertGrpcError(t, err, tc.code, "") + testhelper.RequireGrpcError(t, err, tc.code) } }) } diff --git a/internal/service/commit/filter_shas_with_signatures_test.go b/internal/service/commit/filter_shas_with_signatures_test.go index 1e57d7092e6774db08906073eebd8a7ff34a985b..06eccc1e1d84bd41f78edf9f6e84a39cd9490361 100644 --- a/internal/service/commit/filter_shas_with_signatures_test.go +++ b/internal/service/commit/filter_shas_with_signatures_test.go @@ -82,7 +82,7 @@ func TestFilterShasWithSignaturesValidationError(t *testing.T) { require.NoError(t, stream.CloseSend()) _, err = recvFSWS(stream) - testhelper.AssertGrpcError(t, err, codes.InvalidArgument, "no repo") + testhelper.RequireGrpcError(t, err, codes.InvalidArgument) } func recvFSWS(stream pb.CommitService_FilterShasWithSignaturesClient) ([][]byte, error) { diff --git a/internal/service/commit/find_all_commits_test.go b/internal/service/commit/find_all_commits_test.go index 6d40feb68cd654f7cc4365a37c4c1bc66d510f8f..24a255cea89126a42ffa2bc907a3df34df1d0eb6 100644 --- a/internal/service/commit/find_all_commits_test.go +++ b/internal/service/commit/find_all_commits_test.go @@ -322,7 +322,7 @@ func TestFailedFindAllCommitsRequest(t *testing.T) { } err = drainFindAllCommitsResponse(c) - testhelper.AssertGrpcError(t, err, testCase.code, "") + testhelper.RequireGrpcError(t, err, testCase.code) }) } } diff --git a/internal/service/commit/find_commit_test.go b/internal/service/commit/find_commit_test.go index ab5b8d0a852677b929cb90f26e8eef3074733ae3..cb7694f82071a8b43b3ea17329ec83e7a1b5e050 100644 --- a/internal/service/commit/find_commit_test.go +++ b/internal/service/commit/find_commit_test.go @@ -257,7 +257,7 @@ func TestFailedFindCommitRequest(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() _, err := client.FindCommit(ctx, request) - testhelper.AssertGrpcError(t, err, codes.InvalidArgument, "") + testhelper.RequireGrpcError(t, err, codes.InvalidArgument) }) } } diff --git a/internal/service/commit/find_commits_test.go b/internal/service/commit/find_commits_test.go index b72f81d5d00b51616f5425fad10fe39c829c2de2..2fdca1020e462a33850b0b6380e1ea3d8e717ae5 100644 --- a/internal/service/commit/find_commits_test.go +++ b/internal/service/commit/find_commits_test.go @@ -386,7 +386,7 @@ func TestFailureFindCommitsRequest(t *testing.T) { _, err = stream.Recv() } - testhelper.AssertGrpcError(t, err, tc.code, "") + testhelper.RequireGrpcError(t, err, tc.code) }) } } diff --git a/internal/service/commit/last_commit_for_path_test.go b/internal/service/commit/last_commit_for_path_test.go index ffc5874b55b0aaa7be44b447247962caf607ee34..58e234d731186e92c8f52c9a7252fc32c15f9f89 100644 --- a/internal/service/commit/last_commit_for_path_test.go +++ b/internal/service/commit/last_commit_for_path_test.go @@ -131,7 +131,7 @@ func TestFailedLastCommitForPathRequest(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() _, err := client.LastCommitForPath(ctx, testCase.request) - testhelper.AssertGrpcError(t, err, testCase.code, "") + testhelper.RequireGrpcError(t, err, testCase.code) }) } } diff --git a/internal/service/commit/list_files_test.go b/internal/service/commit/list_files_test.go index dea1ae6b59a8c5671d7fdb99324810caa99ec1f9..acd93e609d559d8b9da54c78482809d081fc1b1f 100644 --- a/internal/service/commit/list_files_test.go +++ b/internal/service/commit/list_files_test.go @@ -171,7 +171,7 @@ func TestListFilesFailure(t *testing.T) { } err = drainListFilesResponse(c) - testhelper.AssertGrpcError(t, err, test.code, "") + testhelper.RequireGrpcError(t, err, test.code) }) } } diff --git a/internal/service/commit/raw_blame_test.go b/internal/service/commit/raw_blame_test.go index 2b633d51995bf69267642d7b2686c3eb0febd894..aa3d3c39dc5fc860b059b75c5e3f262a326990d5 100644 --- a/internal/service/commit/raw_blame_test.go +++ b/internal/service/commit/raw_blame_test.go @@ -133,7 +133,7 @@ func TestFailedRawBlameRequest(t *testing.T) { t.Fatal(err) } - testhelper.AssertGrpcError(t, drainRawBlameResponse(c), testCase.code, "") + testhelper.RequireGrpcError(t, drainRawBlameResponse(c), testCase.code) }) } } diff --git a/internal/service/commit/stats_test.go b/internal/service/commit/stats_test.go index 0c425c85ff766c75e5efaf43d5bdfb98a4a5d0ef..bf0d7e34a2d3851f8789bc1f21eb779445882a94 100644 --- a/internal/service/commit/stats_test.go +++ b/internal/service/commit/stats_test.go @@ -95,7 +95,7 @@ func TestCommitStatsFailure(t *testing.T) { for _, tc := range tests { t.Run(tc.desc, func(t *testing.T) { _, err := client.CommitStats(ctx, &pb.CommitStatsRequest{Repository: tc.repo, Revision: tc.revision}) - testhelper.AssertGrpcError(t, err, tc.err, "") + testhelper.RequireGrpcError(t, err, tc.err) }) } } diff --git a/internal/service/commit/tree_entries_test.go b/internal/service/commit/tree_entries_test.go index 8158291f5b2cf4817a9dd20457f989766fe7be28..209603cd74531c7e12b4dca573439a04efefc4aa 100644 --- a/internal/service/commit/tree_entries_test.go +++ b/internal/service/commit/tree_entries_test.go @@ -377,7 +377,7 @@ func TestFailedGetTreeEntriesRequestDueToValidationError(t *testing.T) { } err = drainTreeEntriesResponse(c) - testhelper.AssertGrpcError(t, err, codes.InvalidArgument, "") + testhelper.RequireGrpcError(t, err, codes.InvalidArgument) }) } } diff --git a/internal/service/commit/tree_entry_test.go b/internal/service/commit/tree_entry_test.go index ecf2159a96d60414f4b5826dd8f2cb3e9f700021..4202b2affec4faaf4904a75bc0c5ddbd87d89f01 100644 --- a/internal/service/commit/tree_entry_test.go +++ b/internal/service/commit/tree_entry_test.go @@ -188,7 +188,7 @@ func TestFailedTreeEntryRequestDueToValidationError(t *testing.T) { } err = drainTreeEntryResponse(c) - testhelper.AssertGrpcError(t, err, codes.InvalidArgument, "") + testhelper.RequireGrpcError(t, err, codes.InvalidArgument) }) } } diff --git a/internal/service/conflicts/list_conflict_files_test.go b/internal/service/conflicts/list_conflict_files_test.go index e9013f7cf8acfd458678829f7ac77e4f730a88fd..993b49426499ab0a76aed7ed5f9dae75afb4fa6a 100644 --- a/internal/service/conflicts/list_conflict_files_test.go +++ b/internal/service/conflicts/list_conflict_files_test.go @@ -113,7 +113,7 @@ func TestFailedListConflictFilesRequestDueToConflictSideMissing(t *testing.T) { } c, _ := client.ListConflictFiles(ctx, request) - testhelper.AssertGrpcError(t, drainListConflictFilesResponse(c), codes.FailedPrecondition, "") + testhelper.RequireGrpcError(t, drainListConflictFilesResponse(c), codes.FailedPrecondition) } func TestFailedListConflictFilesRequestDueToValidation(t *testing.T) { @@ -169,7 +169,7 @@ func TestFailedListConflictFilesRequestDueToValidation(t *testing.T) { defer cancel() c, _ := client.ListConflictFiles(ctx, testCase.request) - testhelper.AssertGrpcError(t, drainListConflictFilesResponse(c), testCase.code, "") + testhelper.RequireGrpcError(t, drainListConflictFilesResponse(c), testCase.code) }) } } diff --git a/internal/service/conflicts/resolve_conflicts_test.go b/internal/service/conflicts/resolve_conflicts_test.go index 775695a6ce8c6120fb48723b5c9b005233f620e8..30c3796c2311b32aab9ee984bed697b2aafd4965 100644 --- a/internal/service/conflicts/resolve_conflicts_test.go +++ b/internal/service/conflicts/resolve_conflicts_test.go @@ -302,7 +302,7 @@ func TestFailedResolveConflictsRequestDueToValidation(t *testing.T) { require.NoError(t, stream.Send(headerRequest)) _, err = stream.CloseAndRecv() - testhelper.AssertGrpcError(t, err, testCase.code, "") + testhelper.RequireGrpcError(t, err, testCase.code) }) } } diff --git a/internal/service/diff/commit_test.go b/internal/service/diff/commit_test.go index a5891d366f4b0df03f88c0d049bf9b15759be6b1..967e4d4d11718b69512745155dd57d94ff73eec7 100644 --- a/internal/service/diff/commit_test.go +++ b/internal/service/diff/commit_test.go @@ -650,7 +650,7 @@ func TestFailedCommitDiffRequestDueToValidationError(t *testing.T) { } err = drainCommitDiffResponse(c) - testhelper.AssertGrpcError(t, err, codes.InvalidArgument, "") + testhelper.RequireGrpcError(t, err, codes.InvalidArgument) }) } } @@ -677,7 +677,7 @@ func TestFailedCommitDiffRequestWithNonExistentCommit(t *testing.T) { } err = drainCommitDiffResponse(c) - testhelper.AssertGrpcError(t, err, codes.Unavailable, "") + testhelper.RequireGrpcError(t, err, codes.Unavailable) } func TestSuccessfulCommitDeltaRequest(t *testing.T) { @@ -903,7 +903,7 @@ func TestFailedCommitDeltaRequestDueToValidationError(t *testing.T) { } err = drainCommitDeltaResponse(c) - testhelper.AssertGrpcError(t, err, codes.InvalidArgument, "") + testhelper.RequireGrpcError(t, err, codes.InvalidArgument) }) } } @@ -930,7 +930,7 @@ func TestFailedCommitDeltaRequestWithNonExistentCommit(t *testing.T) { } err = drainCommitDeltaResponse(c) - testhelper.AssertGrpcError(t, err, codes.Unavailable, "") + testhelper.RequireGrpcError(t, err, codes.Unavailable) } func drainCommitDiffResponse(c pb.Diff_CommitDiffClient) error { diff --git a/internal/service/diff/raw_test.go b/internal/service/diff/raw_test.go index 21c85867c50edfb1ef7050dcece7fe27a1b1122a..52cdc655e05c4deeea5c807503b9490e25b2a092 100644 --- a/internal/service/diff/raw_test.go +++ b/internal/service/diff/raw_test.go @@ -107,7 +107,7 @@ func TestFailedRawDiffRequestDueToValidations(t *testing.T) { defer cancel() c, _ := client.RawDiff(ctx, testCase.request) - testhelper.AssertGrpcError(t, drainRawDiffResponse(c), testCase.code, "") + testhelper.RequireGrpcError(t, drainRawDiffResponse(c), testCase.code) }) } } @@ -199,7 +199,7 @@ func TestFailedRawPatchRequestDueToValidations(t *testing.T) { defer cancel() c, _ := client.RawPatch(ctx, testCase.request) - testhelper.AssertGrpcError(t, drainRawPatchResponse(c), testCase.code, "") + testhelper.RequireGrpcError(t, drainRawPatchResponse(c), testCase.code) }) } } diff --git a/internal/service/notifications/post_receive_test.go b/internal/service/notifications/post_receive_test.go index 6d9e2d4af6719800ce664b8f77e57af20052a565..5e77f9f2084e8070b02fcac123c5ecc99859cb7a 100644 --- a/internal/service/notifications/post_receive_test.go +++ b/internal/service/notifications/post_receive_test.go @@ -45,7 +45,7 @@ func TestEmptyPostReceiveRequest(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() _, err := client.PostReceive(ctx, rpcRequest) - testhelper.AssertGrpcError(t, err, codes.InvalidArgument, "") + testhelper.RequireGrpcError(t, err, codes.InvalidArgument) } func runNotificationsServer(t *testing.T) (*grpc.Server, string) { diff --git a/internal/service/operations/branches_test.go b/internal/service/operations/branches_test.go index 82b3d01911e7738af86598619449a8726d369d57..b6b67f92140774f65d28a4938f13ece2037fc68c 100644 --- a/internal/service/operations/branches_test.go +++ b/internal/service/operations/branches_test.go @@ -239,7 +239,7 @@ func TestFailedUserCreateBranchRequest(t *testing.T) { defer cancel() _, err := client.UserCreateBranch(ctx, request) - testhelper.AssertGrpcError(t, err, testCase.code, "") + testhelper.RequireGrpcError(t, err, testCase.code) }) } } @@ -383,7 +383,7 @@ func TestFailedUserDeleteBranchDueToValidation(t *testing.T) { defer cancel() _, err := client.UserDeleteBranch(ctx, testCase.request) - testhelper.AssertGrpcError(t, err, testCase.code, "") + testhelper.RequireGrpcError(t, err, testCase.code) }) } } diff --git a/internal/service/operations/cherry_pick_test.go b/internal/service/operations/cherry_pick_test.go index 36f21d1cb5f96e13fa6f4e65037fb4e2f254fbb9..6c64b4378f911f31e97d4e76b7f2aecbbac0525e 100644 --- a/internal/service/operations/cherry_pick_test.go +++ b/internal/service/operations/cherry_pick_test.go @@ -261,7 +261,7 @@ func TestFailedUserCherryPickRequestDueToValidations(t *testing.T) { ctx := metadata.NewOutgoingContext(ctxOuter, md) _, err := client.UserCherryPick(ctx, testCase.request) - testhelper.AssertGrpcError(t, err, testCase.code, "") + testhelper.RequireGrpcError(t, err, testCase.code) }) } } diff --git a/internal/service/operations/commit_files_test.go b/internal/service/operations/commit_files_test.go index ed6919fe71ba30071b7d54a1eb70bb0a42412dbc..5ab3a44c30550b076a1a884350f86a628dc6e5c0 100644 --- a/internal/service/operations/commit_files_test.go +++ b/internal/service/operations/commit_files_test.go @@ -232,7 +232,7 @@ func TestFailedUserCommitFilesRequest(t *testing.T) { require.NoError(t, stream.Send(tc.req)) _, err = stream.CloseAndRecv() - testhelper.AssertGrpcError(t, err, codes.InvalidArgument, tc.desc) + testhelper.RequireGrpcError(t, err, codes.InvalidArgument) }) } } diff --git a/internal/service/operations/merge_test.go b/internal/service/operations/merge_test.go index 932d56fe51970e2dcc9a87a10a792de433526967..fb75f3bb9baa514ad4f702c13eff765ac5bb9e68 100644 --- a/internal/service/operations/merge_test.go +++ b/internal/service/operations/merge_test.go @@ -414,7 +414,7 @@ func TestFailedUserFFBranchRequest(t *testing.T) { CommitId: testCase.commitID, } _, err := client.UserFFBranch(ctx, request) - testhelper.AssertGrpcError(t, err, testCase.code, "") + testhelper.RequireGrpcError(t, err, testCase.code) }) } } diff --git a/internal/service/operations/rebase_test.go b/internal/service/operations/rebase_test.go index 22f67ba9396ef8b458a22a98da072e921073b385..9de5af113f3072a8970c353d17caf5720b89bc10 100644 --- a/internal/service/operations/rebase_test.go +++ b/internal/service/operations/rebase_test.go @@ -290,7 +290,7 @@ func TestFailedUserRebaseRequestDueToValidations(t *testing.T) { ctx := metadata.NewOutgoingContext(ctxOuter, md) _, err := client.UserRebase(ctx, testCase.request) - testhelper.AssertGrpcError(t, err, testCase.code, "") + testhelper.RequireGrpcError(t, err, testCase.code) }) } } diff --git a/internal/service/operations/revert_test.go b/internal/service/operations/revert_test.go index a6132c1954bf2fb3befa0adf6480e65f07b355ca..e8e32158da99df510e53c9bbb9b99cf41ec17a55 100644 --- a/internal/service/operations/revert_test.go +++ b/internal/service/operations/revert_test.go @@ -258,7 +258,7 @@ func TestFailedUserRevertRequestDueToValidations(t *testing.T) { ctx := metadata.NewOutgoingContext(ctxOuter, md) _, err := client.UserRevert(ctx, testCase.request) - testhelper.AssertGrpcError(t, err, testCase.code, "") + testhelper.RequireGrpcError(t, err, testCase.code) }) } } diff --git a/internal/service/operations/squash_test.go b/internal/service/operations/squash_test.go index f256cdb6ad30cf05b1351519effbc54ac3c7989f..fe1eea846e90723cbc96562e2974ce48c13ee785 100644 --- a/internal/service/operations/squash_test.go +++ b/internal/service/operations/squash_test.go @@ -229,7 +229,7 @@ func TestFailedUserSquashRequestDueToValidations(t *testing.T) { defer cancel() _, err := client.UserSquash(ctx, testCase.request) - testhelper.AssertGrpcError(t, err, testCase.code, testCase.desc) + testhelper.RequireGrpcError(t, err, testCase.code) }) } } diff --git a/internal/service/operations/tags_test.go b/internal/service/operations/tags_test.go index a2f18b1ea7724b6d1e5ac88441e340d86412602c..c695a8762f6baadd277056a5ca7b4a73948e9128 100644 --- a/internal/service/operations/tags_test.go +++ b/internal/service/operations/tags_test.go @@ -285,7 +285,7 @@ func TestFailedUserDeleteTagRequestDueToValidation(t *testing.T) { defer cancel() _, err := client.UserDeleteTag(ctx, testCase.request) - testhelper.AssertGrpcError(t, err, testCase.code, "") + testhelper.RequireGrpcError(t, err, testCase.code) }) } } @@ -476,7 +476,7 @@ func TestFailedUserCreateTagRequestDueToValidation(t *testing.T) { defer cancel() _, err := client.UserCreateTag(ctx, request) - testhelper.AssertGrpcError(t, err, testCase.code, "") + testhelper.RequireGrpcError(t, err, testCase.code) }) } } diff --git a/internal/service/ref/branches_test.go b/internal/service/ref/branches_test.go index 31c568b9dccbdf026b8650a2b4b4f05b3341b917..d1860c53fc4f5688135ea54c856231fae5ece06d 100644 --- a/internal/service/ref/branches_test.go +++ b/internal/service/ref/branches_test.go @@ -219,7 +219,7 @@ func TestFailedDeleteBranchRequest(t *testing.T) { defer cancel() _, err := client.DeleteBranch(ctx, request) - testhelper.AssertGrpcError(t, err, testCase.code, "") + testhelper.RequireGrpcError(t, err, testCase.code) }) } } @@ -324,7 +324,7 @@ func TestFailedFindBranchRequest(t *testing.T) { defer cancel() _, err := client.FindBranch(ctx, request) - testhelper.AssertGrpcError(t, err, testCase.code, "") + testhelper.RequireGrpcError(t, err, testCase.code) }) } } diff --git a/internal/service/ref/delete_refs_test.go b/internal/service/ref/delete_refs_test.go index 05c74d3ef89f380c328457690f880be667ac9e8e..54487cec860f13556ab6796c482473dbd1e9b57d 100644 --- a/internal/service/ref/delete_refs_test.go +++ b/internal/service/ref/delete_refs_test.go @@ -161,7 +161,7 @@ func TestFailedDeleteRefsDueToValidation(t *testing.T) { defer cancel() _, err := client.DeleteRefs(ctx, tc.request) - testhelper.AssertGrpcError(t, err, tc.code, "") + testhelper.RequireGrpcError(t, err, tc.code) }) } } diff --git a/internal/service/ref/refs_test.go b/internal/service/ref/refs_test.go index 4d593117e961e0a7e6db58ccb6d9172486a90037..134e43b7c34332ad7cec616d7ee265729e10b2e7 100644 --- a/internal/service/ref/refs_test.go +++ b/internal/service/ref/refs_test.go @@ -573,7 +573,7 @@ func TestInvalidFindAllTagsRequest(t *testing.T) { _, recvError = c.Recv() } - testhelper.AssertGrpcError(t, recvError, codes.InvalidArgument, "") + testhelper.RequireGrpcError(t, recvError, codes.InvalidArgument) }) } } @@ -927,7 +927,7 @@ func TestInvalidFindAllBranchesRequest(t *testing.T) { _, recvError = c.Recv() } - testhelper.AssertGrpcError(t, recvError, codes.InvalidArgument, "") + testhelper.RequireGrpcError(t, recvError, codes.InvalidArgument) }) } } @@ -1005,7 +1005,7 @@ func TestListTagNamesContainingCommit(t *testing.T) { if err == io.EOF { break } else if tc.code != codes.OK { - testhelper.AssertGrpcError(t, err, tc.code, "") + testhelper.RequireGrpcError(t, err, tc.code) return } @@ -1099,7 +1099,7 @@ func TestListBranchNamesContainingCommit(t *testing.T) { if err == io.EOF { break } else if tc.code != codes.OK { - testhelper.AssertGrpcError(t, err, tc.code, "") + testhelper.RequireGrpcError(t, err, tc.code) return } diff --git a/internal/service/ref/tag_messages_test.go b/internal/service/ref/tag_messages_test.go index 0c29ca768ab9b0ce255d4f8b9273445afd373c47..3361026d28520681be35a8148457b2a376521827 100644 --- a/internal/service/ref/tag_messages_test.go +++ b/internal/service/ref/tag_messages_test.go @@ -93,7 +93,7 @@ func TestFailedGetTagMessagesRequest(t *testing.T) { } } - testhelper.AssertGrpcError(t, err, testCase.code, "") + testhelper.RequireGrpcError(t, err, testCase.code) }) } } diff --git a/internal/service/remote/fetch_internal_remote_test.go b/internal/service/remote/fetch_internal_remote_test.go index fbcd706e0aeec40b3562b786022cc7595aa786a7..454f51cecf8ee90fa8015beaf2ba93203d38cc63 100644 --- a/internal/service/remote/fetch_internal_remote_test.go +++ b/internal/service/remote/fetch_internal_remote_test.go @@ -110,7 +110,7 @@ func TestFailedFetchInternalRemoteDueToValidations(t *testing.T) { t.Run(tc.desc, func(t *testing.T) { _, err := client.FetchInternalRemote(ctx, tc.request) - testhelper.AssertGrpcError(t, err, codes.InvalidArgument, tc.desc) + testhelper.RequireGrpcError(t, err, codes.InvalidArgument) }) } } diff --git a/internal/service/remote/remotes_test.go b/internal/service/remote/remotes_test.go index 5c18e90feb41cc3e32144b5f2aab201c2fec006e..a3c33e1ff5ee0afdff69b1d212073424b0da1268 100644 --- a/internal/service/remote/remotes_test.go +++ b/internal/service/remote/remotes_test.go @@ -144,7 +144,7 @@ func TestFailedAddRemoteDueToValidation(t *testing.T) { } _, err := client.AddRemote(ctx, request) - testhelper.AssertGrpcError(t, err, codes.InvalidArgument, "") + testhelper.RequireGrpcError(t, err, codes.InvalidArgument) }) } } @@ -215,7 +215,7 @@ func TestFailedRemoveRemoteDueToValidation(t *testing.T) { request := &pb.RemoveRemoteRequest{Repository: testRepo} // Remote name empty _, err := client.RemoveRemote(ctx, request) - testhelper.AssertGrpcError(t, err, codes.InvalidArgument, "") + testhelper.RequireGrpcError(t, err, codes.InvalidArgument) } func TestFindRemoteRepository(t *testing.T) { @@ -266,7 +266,7 @@ func TestFailedFindRemoteRepository(t *testing.T) { if tc.code == codes.OK { require.NoError(t, err) } else { - testhelper.AssertGrpcError(t, err, tc.code, "") + testhelper.RequireGrpcError(t, err, tc.code) continue } diff --git a/internal/service/remote/update_remote_mirror_test.go b/internal/service/remote/update_remote_mirror_test.go index 07ed5eee41312f38495d1d6467e722165a59cf92..2bb11a014c594d8bce813b2eddd89ef73d6b81c3 100644 --- a/internal/service/remote/update_remote_mirror_test.go +++ b/internal/service/remote/update_remote_mirror_test.go @@ -119,7 +119,7 @@ func TestFailedUpdateRemoteMirrorRequestDueToValidation(t *testing.T) { require.NoError(t, stream.Send(tc.request)) _, err = stream.CloseAndRecv() - testhelper.AssertGrpcError(t, err, codes.InvalidArgument, tc.desc) + testhelper.RequireGrpcError(t, err, codes.InvalidArgument) }) } } diff --git a/internal/service/repository/apply_gitattributes_test.go b/internal/service/repository/apply_gitattributes_test.go index 7fcabb29786989822863b541be9e08ef220e6449..76688c92d277370ee593585c9aa4dbce1feba385 100644 --- a/internal/service/repository/apply_gitattributes_test.go +++ b/internal/service/repository/apply_gitattributes_test.go @@ -120,7 +120,7 @@ func TestApplyGitattributesFailure(t *testing.T) { req := &pb.ApplyGitattributesRequest{Repository: test.repo, Revision: test.revision} _, err := client.ApplyGitattributes(ctx, req) - testhelper.AssertGrpcError(t, err, test.code, "") + testhelper.RequireGrpcError(t, err, test.code) }) } } diff --git a/internal/service/repository/archive_test.go b/internal/service/repository/archive_test.go index 148ecebf4368b92b058f1d225a4d7bb471b77dc2..2f543f373d5bc31ad01260ca4f8f6f7a13865a85 100644 --- a/internal/service/repository/archive_test.go +++ b/internal/service/repository/archive_test.go @@ -155,7 +155,7 @@ func TestGetArchiveFailure(t *testing.T) { require.NoError(t, err) _, err = consumeArchive(stream) - testhelper.AssertGrpcError(t, err, tc.code, "") + testhelper.RequireGrpcError(t, err, tc.code) }) } } diff --git a/internal/service/repository/calculate_checksum_test.go b/internal/service/repository/calculate_checksum_test.go index a5c2f029a3955c22c5b2744c68881b26cc790fc9..b507c6abd0256b6e522596edcd863d8ae8d0baef 100644 --- a/internal/service/repository/calculate_checksum_test.go +++ b/internal/service/repository/calculate_checksum_test.go @@ -75,7 +75,7 @@ func TestBrokenRepositoryCalculateChecksum(t *testing.T) { defer cancelCtx() _, err := client.CalculateChecksum(testCtx, request) - testhelper.AssertGrpcError(t, err, codes.DataLoss, "not a git repository") + testhelper.RequireGrpcError(t, err, codes.DataLoss) } func TestFailedCalculateChecksum(t *testing.T) { @@ -109,6 +109,6 @@ func TestFailedCalculateChecksum(t *testing.T) { defer cancelCtx() _, err := client.CalculateChecksum(testCtx, testCase.request) - testhelper.AssertGrpcError(t, err, testCase.code, "") + testhelper.RequireGrpcError(t, err, testCase.code) } } diff --git a/internal/service/repository/create_bundle_test.go b/internal/service/repository/create_bundle_test.go index 559c3c64f3b09bd219379ef2e50e027612b1dcf1..6efe22338e0bf4093d13a7cf6f402011cb278063 100644 --- a/internal/service/repository/create_bundle_test.go +++ b/internal/service/repository/create_bundle_test.go @@ -83,7 +83,7 @@ func TestFailedCreateBundleRequestDueToValidations(t *testing.T) { _, err = stream.Recv() require.NotEqual(t, io.EOF, err) - testhelper.AssertGrpcError(t, err, testCase.code, "") + testhelper.RequireGrpcError(t, err, testCase.code) }) } } diff --git a/internal/service/repository/create_from_bundle_test.go b/internal/service/repository/create_from_bundle_test.go index 18ed59edccf76e26a370b49c4c76a8ff5d01e023..3c2cbdd20b6fe137b773d01f022b117c7783522a 100644 --- a/internal/service/repository/create_from_bundle_test.go +++ b/internal/service/repository/create_from_bundle_test.go @@ -94,5 +94,5 @@ func TestFailedCreateRepositoryFromBundleRequestDueToValidations(t *testing.T) { require.NoError(t, stream.Send(&pb.CreateRepositoryFromBundleRequest{})) _, err = stream.CloseAndRecv() - testhelper.AssertGrpcError(t, err, codes.InvalidArgument, "") + testhelper.RequireGrpcError(t, err, codes.InvalidArgument) } diff --git a/internal/service/repository/create_from_snapshot_test.go b/internal/service/repository/create_from_snapshot_test.go index c44630810283c929f7add22e6f84faf6de4874fb..4730bbf43298935fe9e94c04b8fe30911c94a267 100644 --- a/internal/service/repository/create_from_snapshot_test.go +++ b/internal/service/repository/create_from_snapshot_test.go @@ -118,7 +118,7 @@ func TestCreateRepositoryFromSnapshotFailsIfRepositoryExists(t *testing.T) { req := &pb.CreateRepositoryFromSnapshotRequest{Repository: testRepo} rsp, err := createFromSnapshot(t, req) - testhelper.AssertGrpcError(t, err, codes.InvalidArgument, "destination directory exists") + testhelper.RequireGrpcError(t, err, codes.InvalidArgument) require.Nil(t, rsp) } @@ -132,7 +132,7 @@ func TestCreateRepositoryFromSnapshotFailsIfBadURL(t *testing.T) { } rsp, err := createFromSnapshot(t, req) - testhelper.AssertGrpcError(t, err, codes.InvalidArgument, "Bad HTTP URL") + testhelper.RequireGrpcError(t, err, codes.InvalidArgument) require.Nil(t, rsp) } @@ -151,7 +151,7 @@ func TestCreateRepositoryFromSnapshotFailsIfBadAuth(t *testing.T) { } rsp, err := createFromSnapshot(t, req) - testhelper.AssertGrpcError(t, err, codes.Internal, "HTTP server: 401 Unauthorized") + testhelper.RequireGrpcError(t, err, codes.Internal) require.Nil(t, rsp) } @@ -170,7 +170,7 @@ func TestCreateRepositoryFromSnapshotFailsIfHttp404(t *testing.T) { } rsp, err := createFromSnapshot(t, req) - testhelper.AssertGrpcError(t, err, codes.Internal, "HTTP server: 404 Not Found") + testhelper.RequireGrpcError(t, err, codes.Internal) require.Nil(t, rsp) } @@ -189,7 +189,7 @@ func TestCreateRepositoryFromSnapshotDoesNotFollowRedirects(t *testing.T) { } rsp, err := createFromSnapshot(t, req) - testhelper.AssertGrpcError(t, err, codes.Internal, "HTTP server: 302 Found") + testhelper.RequireGrpcError(t, err, codes.Internal) require.Nil(t, rsp) } diff --git a/internal/service/repository/create_from_url_test.go b/internal/service/repository/create_from_url_test.go index ba8aa6d1616ecae5e16b00d02f80845d4a056313..79e997245aa6a168bc85ad6a634a5c21e9bd95f5 100644 --- a/internal/service/repository/create_from_url_test.go +++ b/internal/service/repository/create_from_url_test.go @@ -102,7 +102,7 @@ func TestFailedCreateRepositoryFromURLRequestDueToExistingTarget(t *testing.T) { } _, err = client.CreateRepositoryFromURL(ctx, req) - testhelper.AssertGrpcError(t, err, codes.InvalidArgument, "") + testhelper.RequireGrpcError(t, err, codes.InvalidArgument) }) } } diff --git a/internal/service/repository/create_test.go b/internal/service/repository/create_test.go index 5f2e6f6fbfceb00da27d375163954f5ef49e4bfd..5817af8e7adc495e678b822522d7300c29a85ad6 100644 --- a/internal/service/repository/create_test.go +++ b/internal/service/repository/create_test.go @@ -75,7 +75,7 @@ func TestCreateRepositoryFailure(t *testing.T) { Repository: &pb.Repository{StorageName: "default", RelativePath: "foo.git"}, }) - testhelper.AssertGrpcError(t, err, codes.Unknown, "") + testhelper.RequireGrpcError(t, err, codes.Unknown) } func TestCreateRepositoryFailureInvalidArgs(t *testing.T) { @@ -103,7 +103,7 @@ func TestCreateRepositoryFailureInvalidArgs(t *testing.T) { _, err := client.CreateRepository(ctx, &pb.CreateRepositoryRequest{Repository: tc.repo}) require.Error(t, err) - testhelper.AssertGrpcError(t, err, tc.code, "") + testhelper.RequireGrpcError(t, err, tc.code) }) } } diff --git a/internal/service/repository/fetch_remote_test.go b/internal/service/repository/fetch_remote_test.go index 8f18d4af36ce07567a7cdff4b80e3b148031bc2d..1182b998aad717203d25db12ee6b4fa3ed2e1fad 100644 --- a/internal/service/repository/fetch_remote_test.go +++ b/internal/service/repository/fetch_remote_test.go @@ -88,7 +88,7 @@ func TestFetchRemoteFailure(t *testing.T) { defer cancel() resp, err := client.FetchRemote(ctx, tc.req) - testhelper.AssertGrpcError(t, err, tc.code, tc.err) + testhelper.RequireGrpcError(t, err, tc.code) assert.Error(t, err) assert.Nil(t, resp) }) diff --git a/internal/service/repository/fetch_test.go b/internal/service/repository/fetch_test.go index 28012bc9c5ac66e30485aa7222841866577feeec..9fcd6f59d5ec8c37f21dabbd0878d87416669f87 100644 --- a/internal/service/repository/fetch_test.go +++ b/internal/service/repository/fetch_test.go @@ -169,7 +169,7 @@ func TestFetchFullServerRequiresAuthentication(t *testing.T) { client := healthpb.NewHealthClient(conn) _, err = client.Check(ctx, &healthpb.HealthCheckRequest{}) - testhelper.AssertGrpcError(t, err, codes.Unauthenticated, "") + testhelper.RequireGrpcError(t, err, codes.Unauthenticated) } func newTestRepo(t *testing.T, relativePath string) (*pb.Repository, string) { diff --git a/internal/service/repository/fork_test.go b/internal/service/repository/fork_test.go index a9ea3ee5f3f4514fdea5ce496e5c38dad3f10462..0d06858e7b7d3a4cc25eca5ed6687d3a1abb34f5 100644 --- a/internal/service/repository/fork_test.go +++ b/internal/service/repository/fork_test.go @@ -116,7 +116,7 @@ func TestFailedCreateForkRequestDueToExistingTarget(t *testing.T) { } _, err = client.CreateFork(ctx, req) - testhelper.AssertGrpcError(t, err, codes.InvalidArgument, "") + testhelper.RequireGrpcError(t, err, codes.InvalidArgument) }) } } diff --git a/internal/service/repository/gc_test.go b/internal/service/repository/gc_test.go index 951f983c4947e1e1e4c0a5ce25b4b1570f18a1b3..f9e9fa5111ee70a979f5a092a555cee61265171e 100644 --- a/internal/service/repository/gc_test.go +++ b/internal/service/repository/gc_test.go @@ -116,7 +116,7 @@ func TestGarbageCollectDeletesRefsLocks(t *testing.T) { createFileWithTimes(deleteLockPath, oldTime) c, err := client.GarbageCollect(ctx, req) - testhelper.AssertGrpcError(t, err, codes.Internal, "GarbageCollect: cmd wait") + testhelper.RequireGrpcError(t, err, codes.Internal) assert.Nil(t, c) // Sanity checks @@ -154,7 +154,7 @@ func TestGarbageCollectFailure(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() _, err := client.GarbageCollect(ctx, &pb.GarbageCollectRequest{Repository: test.repo}) - testhelper.AssertGrpcError(t, err, test.code, "") + testhelper.RequireGrpcError(t, err, test.code) }) } diff --git a/internal/service/repository/merge_base_test.go b/internal/service/repository/merge_base_test.go index 4c429deaed96b4d423d020d5c1e09553ce7e0ecc..79688ae69055fe1e81b587b6ec5848f5f4e37149 100644 --- a/internal/service/repository/merge_base_test.go +++ b/internal/service/repository/merge_base_test.go @@ -122,7 +122,7 @@ func TestFailedFindMergeBaseRequestDueToValidations(t *testing.T) { } _, err := client.FindMergeBase(ctx, request) - testhelper.AssertGrpcError(t, err, testCase.code, "") + testhelper.RequireGrpcError(t, err, testCase.code) }) } } diff --git a/internal/service/repository/raw_changes_test.go b/internal/service/repository/raw_changes_test.go index 77e632d5a6a8d3277edaf1ee187d0c03bc10c2e1..0ed8ad654f02694e936ac107072c19f9baaa627b 100644 --- a/internal/service/repository/raw_changes_test.go +++ b/internal/service/repository/raw_changes_test.go @@ -91,7 +91,7 @@ func TestGetRawChangesFailures(t *testing.T) { require.NoError(t, err) _, err = resp.Recv() - testhelper.AssertGrpcError(t, err, tc.code, "") + testhelper.RequireGrpcError(t, err, tc.code) } } diff --git a/internal/service/repository/rebase_in_progress_test.go b/internal/service/repository/rebase_in_progress_test.go index d34165951542fa4a351ef5d96f17935c57fda7ea..ab0c212e3555d50e4c42f7dcfba1cc5110df359e 100644 --- a/internal/service/repository/rebase_in_progress_test.go +++ b/internal/service/repository/rebase_in_progress_test.go @@ -125,7 +125,7 @@ func TestFailedIsRebaseInProgressRequestDueToValidations(t *testing.T) { defer cancel() _, err := client.IsRebaseInProgress(ctx, testCase.request) - testhelper.AssertGrpcError(t, err, testCase.code, "") + testhelper.RequireGrpcError(t, err, testCase.code) }) } } diff --git a/internal/service/repository/repack_test.go b/internal/service/repository/repack_test.go index c443d1f9d36089be8207dd1625ef65e6cc677be1..c3f3bc6d8cbbaa1092d0d85038b2515ccf06b2f2 100644 --- a/internal/service/repository/repack_test.go +++ b/internal/service/repository/repack_test.go @@ -65,7 +65,7 @@ func TestRepackIncrementalFailure(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() _, err := client.RepackIncremental(ctx, &pb.RepackIncrementalRequest{Repository: test.repo}) - testhelper.AssertGrpcError(t, err, test.code, "") + testhelper.RequireGrpcError(t, err, test.code) }) } } @@ -145,7 +145,7 @@ func TestRepackFullFailure(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() _, err := client.RepackFull(ctx, &pb.RepackFullRequest{Repository: test.repo}) - testhelper.AssertGrpcError(t, err, test.code, "") + testhelper.RequireGrpcError(t, err, test.code) }) } } diff --git a/internal/service/repository/search_files_test.go b/internal/service/repository/search_files_test.go index 2679e4715ca29d6aa0aafe8463daa1a0cb9339c5..f81c7d124cb36670cf0913e6470bda754072ad9d 100644 --- a/internal/service/repository/search_files_test.go +++ b/internal/service/repository/search_files_test.go @@ -181,7 +181,7 @@ func TestSearchFilesByContentFailure(t *testing.T) { require.NoError(t, err) _, err = consumeFilenameByContent(stream) - testhelper.AssertGrpcError(t, err, tc.code, tc.msg) + testhelper.RequireGrpcError(t, err, tc.code) }) } } @@ -285,7 +285,7 @@ func TestSearchFilesByNameFailure(t *testing.T) { require.NoError(t, err) _, err = consumeFilenameByName(stream) - testhelper.AssertGrpcError(t, err, tc.code, tc.msg) + testhelper.RequireGrpcError(t, err, tc.code) }) } } diff --git a/internal/service/repository/size_test.go b/internal/service/repository/size_test.go index c3c022d918a4925ed993485a19b7d1ee14ef6ac0..c8aff97fee2a85f752345f905f7310edf9af0e83 100644 --- a/internal/service/repository/size_test.go +++ b/internal/service/repository/size_test.go @@ -77,7 +77,7 @@ func TestFailedRepositorySizeRequest(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() _, err := client.RepositorySize(ctx, request) - testhelper.AssertGrpcError(t, err, codes.InvalidArgument, "") + testhelper.RequireGrpcError(t, err, codes.InvalidArgument) }) } } diff --git a/internal/service/repository/snapshot_test.go b/internal/service/repository/snapshot_test.go index ce0f4e926ed29ff8398724c411f6f93b64621500..d50d73c8b4ad1319d30c339503f8a1483bbfe859 100644 --- a/internal/service/repository/snapshot_test.go +++ b/internal/service/repository/snapshot_test.go @@ -91,7 +91,7 @@ func TestGetSnapshotFailsIfRepositoryMissing(t *testing.T) { req := &pb.GetSnapshotRequest{Repository: testRepo} data, err := getSnapshot(t, req) - testhelper.AssertGrpcError(t, err, codes.NotFound, "not a git repository") + testhelper.RequireGrpcError(t, err, codes.NotFound) require.Empty(t, data) } @@ -106,7 +106,7 @@ func TestGetSnapshotFailsIfRepositoryContainsSymlink(t *testing.T) { req := &pb.GetSnapshotRequest{Repository: testRepo} data, err := getSnapshot(t, req) - testhelper.AssertGrpcError(t, err, codes.Internal, "Building snapshot failed") + testhelper.RequireGrpcError(t, err, codes.Internal) // At least some of the tar file should have been written so far require.NotEmpty(t, data) diff --git a/internal/service/repository/squash_in_progress_test.go b/internal/service/repository/squash_in_progress_test.go index 5d16545aa71ef8fa6656465f06f2978439f20972..97b8df802898430451189fd0c0260f05a3e6d8fb 100644 --- a/internal/service/repository/squash_in_progress_test.go +++ b/internal/service/repository/squash_in_progress_test.go @@ -93,7 +93,7 @@ func TestFailedIsSquashInProgressRequestDueToValidations(t *testing.T) { defer cancel() _, err := client.IsSquashInProgress(ctx, testCase.request) - testhelper.AssertGrpcError(t, err, testCase.code, "") + testhelper.RequireGrpcError(t, err, testCase.code) }) } } diff --git a/internal/service/repository/write_config_test.go b/internal/service/repository/write_config_test.go index f25e0a2df89d9a6ba70db06c02346e7b901ae785..cbd4a3ee971fb78d04e2db7f29ec4745bcedec6e 100644 --- a/internal/service/repository/write_config_test.go +++ b/internal/service/repository/write_config_test.go @@ -80,7 +80,7 @@ func TestWriteConfigFailure(t *testing.T) { defer cancel() c, err := client.WriteConfig(ctx, &pb.WriteConfigRequest{Repository: tc.repo, FullPath: tc.path}) - testhelper.AssertGrpcError(t, err, codes.NotFound, "") + testhelper.RequireGrpcError(t, err, codes.NotFound) require.Nil(t, c) require.Empty(t, c.GetError()) }) diff --git a/internal/service/repository/write_ref_test.go b/internal/service/repository/write_ref_test.go index 9be86546cb3942e662190bf06ff6ddc4c0fb9d5d..3557631da17372795bf2007a3f6cc4e41a7e911c 100644 --- a/internal/service/repository/write_ref_test.go +++ b/internal/service/repository/write_ref_test.go @@ -167,7 +167,7 @@ func TestWriteRefValidationError(t *testing.T) { defer cancel() _, err := client.WriteRef(ctx, tc.req) - testhelper.AssertGrpcError(t, err, codes.InvalidArgument, "") + testhelper.RequireGrpcError(t, err, codes.InvalidArgument) }) } } diff --git a/internal/service/smarthttp/inforefs_test.go b/internal/service/smarthttp/inforefs_test.go index dbb65e2dc4671677decd03f31e779fef9fcc2e15..24ca0760a3165a9486044b0ad0cb789a4d5c67dd 100644 --- a/internal/service/smarthttp/inforefs_test.go +++ b/internal/service/smarthttp/inforefs_test.go @@ -120,7 +120,7 @@ func TestFailureRepoNotFoundInfoRefsReceivePack(t *testing.T) { for err == nil { _, err = c.Recv() } - testhelper.AssertGrpcError(t, err, codes.NotFound, "not a git repository") + testhelper.RequireGrpcError(t, err, codes.NotFound) } func TestFailureRepoNotSetInfoRefsReceivePack(t *testing.T) { @@ -141,7 +141,7 @@ func TestFailureRepoNotSetInfoRefsReceivePack(t *testing.T) { for err == nil { _, err = c.Recv() } - testhelper.AssertGrpcError(t, err, codes.InvalidArgument, "") + testhelper.RequireGrpcError(t, err, codes.InvalidArgument) } func assertGitRefAdvertisement(t *testing.T, rpc, responseBody string, firstLine, lastLine string, middleLines []string) { diff --git a/internal/service/smarthttp/receive_pack_test.go b/internal/service/smarthttp/receive_pack_test.go index cafc84b0efd03034079dd661e35d3a6106698c18..7575d77e144c250d88f1ea66d71c594ecc094dfb 100644 --- a/internal/service/smarthttp/receive_pack_test.go +++ b/internal/service/smarthttp/receive_pack_test.go @@ -131,7 +131,7 @@ func TestFailedReceivePackRequestDueToValidationError(t *testing.T) { stream.CloseSend() err = drainPostReceivePackResponse(stream) - testhelper.AssertGrpcError(t, err, codes.InvalidArgument, "") + testhelper.RequireGrpcError(t, err, codes.InvalidArgument) }) } } diff --git a/internal/service/smarthttp/upload_pack_test.go b/internal/service/smarthttp/upload_pack_test.go index 9922463aad672e353c3aceb05dce8d72ccd0979a..d3f20b2fa3afb4b2499259930d5f38ba42e80e4e 100644 --- a/internal/service/smarthttp/upload_pack_test.go +++ b/internal/service/smarthttp/upload_pack_test.go @@ -143,7 +143,7 @@ func TestUploadPackRequestWithGitConfigOptions(t *testing.T) { // client just sees a grpc unavailable error rpcRequest.GitConfigOptions = []string{"uploadpack.hideRefs=refs/hidden"} response, err = makePostUploadPackRequest(t, serverSocketPath, rpcRequest, requestBodyCopy) - testhelper.AssertGrpcError(t, err, codes.Unavailable, "") + testhelper.RequireGrpcError(t, err, codes.Unavailable) assert.Equal(t, response.String(), "", "Ref is hidden so no response should be received") } @@ -182,7 +182,7 @@ func TestFailedUploadPackRequestDueToValidationError(t *testing.T) { for _, rpcRequest := range rpcRequests { t.Run(fmt.Sprintf("%v", rpcRequest), func(t *testing.T) { _, err := makePostUploadPackRequest(t, serverSocketPath, &rpcRequest, bytes.NewBuffer(nil)) - testhelper.AssertGrpcError(t, err, codes.InvalidArgument, "") + testhelper.RequireGrpcError(t, err, codes.InvalidArgument) }) } } diff --git a/internal/service/ssh/receive_pack_test.go b/internal/service/ssh/receive_pack_test.go index 055d5b27ab8d9da4b67ef9d41ad3948209bac514..9aa6754eb6a1c93f3eae9839fbe7c67112c8f470 100644 --- a/internal/service/ssh/receive_pack_test.go +++ b/internal/service/ssh/receive_pack_test.go @@ -70,7 +70,7 @@ func TestFailedReceivePackRequestDueToValidationError(t *testing.T) { stream.CloseSend() err = drainPostReceivePackResponse(stream) - testhelper.AssertGrpcError(t, err, test.Code, "") + testhelper.RequireGrpcError(t, err, test.Code) }) } } diff --git a/internal/service/ssh/upload_archive_test.go b/internal/service/ssh/upload_archive_test.go index 9b0cea4a95d40fb08b032823c5db086916f693bb..6828082439d30cfc1984fc569f543fbef3dd4300 100644 --- a/internal/service/ssh/upload_archive_test.go +++ b/internal/service/ssh/upload_archive_test.go @@ -61,7 +61,7 @@ func TestFailedUploadArchiveRequestDueToValidationError(t *testing.T) { stream.CloseSend() err = drainUploadArchiveResponse(stream) - testhelper.AssertGrpcError(t, err, test.Code, "") + testhelper.RequireGrpcError(t, err, test.Code) }) } } diff --git a/internal/service/ssh/upload_pack_test.go b/internal/service/ssh/upload_pack_test.go index df98faa7bf62e9a8075ca3994c9fad0ccda9b36e..99a40add006686888f946d37c1cc007de289ea63 100644 --- a/internal/service/ssh/upload_pack_test.go +++ b/internal/service/ssh/upload_pack_test.go @@ -64,7 +64,7 @@ func TestFailedUploadPackRequestDueToValidationError(t *testing.T) { stream.CloseSend() err = drainPostUploadPackResponse(stream) - testhelper.AssertGrpcError(t, err, test.Code, "") + testhelper.RequireGrpcError(t, err, test.Code) }) } } diff --git a/internal/service/wiki/delete_page_test.go b/internal/service/wiki/delete_page_test.go index ec9af319980424e90173629bf907fe7d9581bdfb..5dc4cd40257228afccb1eaf80e890795250ea422 100644 --- a/internal/service/wiki/delete_page_test.go +++ b/internal/service/wiki/delete_page_test.go @@ -181,7 +181,7 @@ func TestFailedWikiDeletePageDueToValidations(t *testing.T) { defer cancel() _, err := client.WikiDeletePage(ctx, testCase.request) - testhelper.AssertGrpcError(t, err, testCase.code, "") + testhelper.RequireGrpcError(t, err, testCase.code) }) } } diff --git a/internal/service/wiki/find_file_test.go b/internal/service/wiki/find_file_test.go index 3ef73d97b23109a200682b53440ecf97dd1e2db5..c23bc109d6837b6ea8ae9139e240fb2366d39b27 100644 --- a/internal/service/wiki/find_file_test.go +++ b/internal/service/wiki/find_file_test.go @@ -178,7 +178,7 @@ func TestFailedWikiFindFileDueToValidation(t *testing.T) { require.NoError(t, err) err = drainWikiFindFileResponse(c) - testhelper.AssertGrpcError(t, err, testCase.code, "") + testhelper.RequireGrpcError(t, err, testCase.code) }) } } diff --git a/internal/service/wiki/find_page_test.go b/internal/service/wiki/find_page_test.go index 44a0e0ac5339f982dcd2b7b8abfb19e718f58af4..955961af38e224cb49737b456887501b55e6998b 100644 --- a/internal/service/wiki/find_page_test.go +++ b/internal/service/wiki/find_page_test.go @@ -318,7 +318,7 @@ func TestFailedWikiFindPageDueToValidation(t *testing.T) { require.NoError(t, err) err = drainWikiFindPageResponse(c) - testhelper.AssertGrpcError(t, err, testCase.code, "") + testhelper.RequireGrpcError(t, err, testCase.code) }) } } diff --git a/internal/service/wiki/formatted_data_test.go b/internal/service/wiki/formatted_data_test.go index fecd8caefe20d3476b3058048e020e50e713e532..8bc45453ae3f88f825dc0df925dc4bdfc87861ca 100644 --- a/internal/service/wiki/formatted_data_test.go +++ b/internal/service/wiki/formatted_data_test.go @@ -117,7 +117,7 @@ func TestFailedWikiGetFormattedDataDueToValidation(t *testing.T) { require.NoError(t, err) err = drainWikiGetFormattedDataResponse(c) - testhelper.AssertGrpcError(t, err, testCase.code, "") + testhelper.RequireGrpcError(t, err, testCase.code) }) } } diff --git a/internal/service/wiki/get_all_pages_test.go b/internal/service/wiki/get_all_pages_test.go index 4fefa4ada0b4bdb18f9db4e95abe94415546861d..c06d282419e466ff431c00a8a8ba5809c97d28e3 100644 --- a/internal/service/wiki/get_all_pages_test.go +++ b/internal/service/wiki/get_all_pages_test.go @@ -81,7 +81,7 @@ func TestFailedWikiGetAllPagesDueToValidation(t *testing.T) { require.NoError(t, err) err = drainWikiGetAllPagesResponse(c) - testhelper.AssertGrpcError(t, err, codes.InvalidArgument, "") + testhelper.RequireGrpcError(t, err, codes.InvalidArgument) } } diff --git a/internal/service/wiki/update_page_test.go b/internal/service/wiki/update_page_test.go index 79fcf28ba08bb67e99d1d24f4691e8204a056096..66d076ee74c65271bc10ff7b0bd7e93f0e682a4a 100644 --- a/internal/service/wiki/update_page_test.go +++ b/internal/service/wiki/update_page_test.go @@ -245,7 +245,7 @@ func TestFailedWikiUpdatePageDueToValidations(t *testing.T) { require.NoError(t, stream.Send(testCase.request)) _, err = stream.CloseAndRecv() - testhelper.AssertGrpcError(t, err, testCase.code, "") + testhelper.RequireGrpcError(t, err, testCase.code) }) } } diff --git a/internal/service/wiki/write_page_test.go b/internal/service/wiki/write_page_test.go index abb471b4e3f4927ee111ecf5c539aa463959f8ee..acf500be5286768ebe243c50098f501994e2247b 100644 --- a/internal/service/wiki/write_page_test.go +++ b/internal/service/wiki/write_page_test.go @@ -318,7 +318,7 @@ func TestFailedWikiWritePageDueToValidations(t *testing.T) { require.NoError(t, stream.Send(testCase.request)) _, err = stream.CloseAndRecv() - testhelper.AssertGrpcError(t, err, testCase.code, "") + testhelper.RequireGrpcError(t, err, testCase.code) }) } } diff --git a/internal/testhelper/testhelper.go b/internal/testhelper/testhelper.go index 892c11b788d00f86ae7fedc568d4866d2cd8917c..849ab380c0128839333bc116b5a5885ce1f8930c 100644 --- a/internal/testhelper/testhelper.go +++ b/internal/testhelper/testhelper.go @@ -124,9 +124,9 @@ func TestRepository() *pb.Repository { return repo } -// AssertGrpcError asserts the passed err is of the same code as expectedCode. Optionally, it can +// RequireGrpcError asserts the passed err is of the same code as expectedCode. Optionally, it can // assert the error contains the text of containsText if the latter is not an empty string. -func AssertGrpcError(t *testing.T, err error, expectedCode codes.Code, containsText string) { +func RequireGrpcError(t *testing.T, err error, expectedCode codes.Code) { if err == nil { t.Fatal("Expected an error, got nil") } @@ -136,10 +136,6 @@ func AssertGrpcError(t *testing.T, err error, expectedCode codes.Code, containsT if code := status.Code(); code != expectedCode { t.Fatalf("Expected an error with code %v, got %v. The error was %v", expectedCode, code, err) } - - if containsText != "" && !strings.Contains(err.Error(), containsText) { - t.Fatalf("Expected an error message containing %v, got %v", containsText, err.Error()) - } } // MustRunCommand runs a command with an optional standard input and returns the standard output, or fails.