From ce2451fa0fc17966739a3faa5e633ca9a946843c Mon Sep 17 00:00:00 2001 From: Pavlo Strokov Date: Thu, 6 Oct 2022 09:22:13 +0300 Subject: config: Simplify error message If relative path is not provided the error message used to include the full Repository entity. It has no much of usage as we don't rely on this data. With it the error message was hard to read and to create an expected results in the tests. It is simplified to have only an error message without the full Repository entity. --- internal/gitaly/config/locator.go | 2 +- internal/gitaly/config/locator_test.go | 4 ++-- internal/gitaly/service/ssh/receive_pack_test.go | 2 +- internal/gitaly/service/ssh/upload_pack_test.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/gitaly/config/locator.go b/internal/gitaly/config/locator.go index 3812c6190..786eb2d45 100644 --- a/internal/gitaly/config/locator.go +++ b/internal/gitaly/config/locator.go @@ -69,7 +69,7 @@ func (l *configLocator) GetPath(repo repository.GitRepo) (string, error) { relativePath := repo.GetRelativePath() if len(relativePath) == 0 { - err := helper.ErrInvalidArgumentf("GetPath: relative path missing from %+v", repo) + err := helper.ErrInvalidArgumentf("GetPath: relative path missing") return "", err } diff --git a/internal/gitaly/config/locator_test.go b/internal/gitaly/config/locator_test.go index 9f34e463d..4b77a5c0f 100644 --- a/internal/gitaly/config/locator_test.go +++ b/internal/gitaly/config/locator_test.go @@ -63,7 +63,7 @@ func TestConfigLocator_GetRepoPath(t *testing.T) { { desc: "relative path is empty", repo: &gitalypb.Repository{StorageName: storageName, RelativePath: ""}, - expErr: helper.ErrInvalidArgumentf(`GetPath: relative path missing from storage_name:"exists"`), + expErr: helper.ErrInvalidArgumentf("GetPath: relative path missing"), }, { desc: "unknown relative path", @@ -161,7 +161,7 @@ func TestConfigLocator_GetPath(t *testing.T) { { desc: "relative path is empty", repo: &gitalypb.Repository{StorageName: storageName, RelativePath: ""}, - expErr: helper.ErrInvalidArgumentf(`GetPath: relative path missing from storage_name:"exists"`), + expErr: helper.ErrInvalidArgumentf("GetPath: relative path missing"), }, { desc: "relative path escapes parent folder", diff --git a/internal/gitaly/service/ssh/receive_pack_test.go b/internal/gitaly/service/ssh/receive_pack_test.go index 0f9317696..7267022b6 100644 --- a/internal/gitaly/service/ssh/receive_pack_test.go +++ b/internal/gitaly/service/ssh/receive_pack_test.go @@ -67,7 +67,7 @@ func TestReceivePack_validation(t *testing.T) { return helper.ErrInvalidArgumentf("repo scoped: invalid Repository") } - return helper.ErrInvalidArgumentf("GetPath: relative path missing from storage_name:\"default\"") + return helper.ErrInvalidArgumentf("GetPath: relative path missing") }(), }, { diff --git a/internal/gitaly/service/ssh/upload_pack_test.go b/internal/gitaly/service/ssh/upload_pack_test.go index 4d6e9e46b..491783e97 100644 --- a/internal/gitaly/service/ssh/upload_pack_test.go +++ b/internal/gitaly/service/ssh/upload_pack_test.go @@ -445,7 +445,7 @@ func TestUploadPack_validation(t *testing.T) { if testhelper.IsPraefectEnabled() { return helper.ErrInvalidArgumentf("repo scoped: invalid Repository") } - return helper.ErrInvalidArgumentf("GetPath: relative path missing from storage_name:%q", "default") + return helper.ErrInvalidArgumentf("GetPath: relative path missing") }(), }, { -- cgit v1.2.3