Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSami Hiltunen <shiltunen@gitlab.com>2023-10-27 16:29:56 +0300
committerSami Hiltunen <shiltunen@gitlab.com>2023-10-31 12:19:38 +0300
commit5f13bea7acdc2d8e91f3890a2bc591e30631f98d (patch)
treed9eac8cedc5f06049c3ab308461f76794623a695
parent7384bee223690562175f5a1339fa7098f4593a5a (diff)
Test beginning a transaction fails without a relative path
This commit adds a test for ensuring we return a proper error when a transaction is begun without a relative path provided. This would not happen in production as we validate relative paths already in the transaction middleware but is here for thoroughness and to ease troubleshooting.
-rw-r--r--internal/gitaly/storage/storagemgr/transaction_manager.go5
-rw-r--r--internal/gitaly/storage/storagemgr/transaction_manager_test.go9
2 files changed, 13 insertions, 1 deletions
diff --git a/internal/gitaly/storage/storagemgr/transaction_manager.go b/internal/gitaly/storage/storagemgr/transaction_manager.go
index 7654edd9f..9099c1cfe 100644
--- a/internal/gitaly/storage/storagemgr/transaction_manager.go
+++ b/internal/gitaly/storage/storagemgr/transaction_manager.go
@@ -49,6 +49,9 @@ var (
errInitializationFailed = errors.New("initializing transaction processing failed")
// errNotDirectory is returned when the repository's path doesn't point to a directory
errNotDirectory = errors.New("repository's path didn't point to a directory")
+ // errRelativePathNotSet is returned when a transaction is begun without providing a relative path
+ // of the target repository.
+ errRelativePathNotSet = errors.New("relative path not set")
)
// InvalidReferenceFormatError is returned when a reference name was invalid.
@@ -225,7 +228,7 @@ func (mgr *TransactionManager) Begin(ctx context.Context, relativePath string, r
if relativePath == "" {
// For now we don't have a use case for transactions that don't target a repository.
// Until support is implemented, error out.
- return nil, errors.New("relative path not set")
+ return nil, errRelativePathNotSet
}
mgr.mutex.Lock()
diff --git a/internal/gitaly/storage/storagemgr/transaction_manager_test.go b/internal/gitaly/storage/storagemgr/transaction_manager_test.go
index a99d1b158..1aaeb9451 100644
--- a/internal/gitaly/storage/storagemgr/transaction_manager_test.go
+++ b/internal/gitaly/storage/storagemgr/transaction_manager_test.go
@@ -4720,6 +4720,15 @@ func TestTransactionManager(t *testing.T) {
},
},
},
+ {
+ desc: "start transaction with empty relative path",
+ steps: steps{
+ StartManager{},
+ Begin{
+ ExpectedError: errRelativePathNotSet,
+ },
+ },
+ },
}
type invalidReferenceTestCase struct {