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:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2020-11-03 09:54:46 +0300
committerPaul Okstad <pokstad@gitlab.com>2020-11-04 08:14:04 +0300
commit1199fb1da41f4b7c3c60d8b380481cd9fe2e95e7 (patch)
treedad367a9b7be5112de09eaee0276bdac9c43b110
parent41429fa9e44624c0c647b47b0a03519f8dd635d3 (diff)
featureset: Simplify description of testcases
Testcases which use the featureset helper currently manually prefix a "disabled " string to the description everywhere. This is annoying and doesn't really help, and in fact we can just move it into the feature set's `String()` method. Refactor the code by renaming the `String()` method to `Desc()` and include the prefix.
-rw-r--r--internal/gitaly/service/conflicts/list_conflict_files_test.go2
-rw-r--r--internal/gitaly/service/operations/branches_test.go16
-rw-r--r--internal/gitaly/service/operations/merge_test.go8
-rw-r--r--internal/gitaly/service/operations/squash_test.go4
-rw-r--r--internal/testhelper/featureset.go7
5 files changed, 20 insertions, 17 deletions
diff --git a/internal/gitaly/service/conflicts/list_conflict_files_test.go b/internal/gitaly/service/conflicts/list_conflict_files_test.go
index f08b12d5e..40572d77f 100644
--- a/internal/gitaly/service/conflicts/list_conflict_files_test.go
+++ b/internal/gitaly/service/conflicts/list_conflict_files_test.go
@@ -27,7 +27,7 @@ func testListConflictFiles(t *testing.T, testcase func(t *testing.T, ctx context
})
for _, featureSet := range featureSets {
- t.Run("disabled "+featureSet.String(), func(t *testing.T) {
+ t.Run(featureSet.Desc(), func(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
diff --git a/internal/gitaly/service/operations/branches_test.go b/internal/gitaly/service/operations/branches_test.go
index b06f34e4e..a78a5c54b 100644
--- a/internal/gitaly/service/operations/branches_test.go
+++ b/internal/gitaly/service/operations/branches_test.go
@@ -104,12 +104,14 @@ func TestSuccessfulGitHooksForUserCreateBranchRequest(t *testing.T) {
})
for _, featureSet := range featureSets {
- ctx, cancel := testhelper.Context()
- defer cancel()
+ t.Run(featureSet.Desc(), func(t *testing.T) {
+ ctx, cancel := testhelper.Context()
+ defer cancel()
- ctx = featureSet.Disable(ctx)
+ ctx = featureSet.Disable(ctx)
- testSuccessfulGitHooksForUserCreateBranchRequest(t, ctx)
+ testSuccessfulGitHooksForUserCreateBranchRequest(t, ctx)
+ })
}
}
@@ -369,7 +371,7 @@ func TestSuccessfulUserDeleteBranchRequest(t *testing.T) {
})
for _, featureSet := range featureSets {
- t.Run("disabled "+featureSet.String(), func(t *testing.T) {
+ t.Run(featureSet.Desc(), func(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
@@ -490,7 +492,7 @@ func TestFailedUserDeleteBranchDueToValidation(t *testing.T) {
}
for _, featureSet := range featureSets {
- t.Run("disabled "+featureSet.String(), func(t *testing.T) {
+ t.Run(featureSet.Desc(), func(t *testing.T) {
for _, testCase := range testCases {
t.Run(testCase.desc, func(t *testing.T) {
ctx, cancel := testhelper.Context()
@@ -533,7 +535,7 @@ func TestFailedUserDeleteBranchDueToHooks(t *testing.T) {
hookContent := []byte("#!/bin/sh\necho GL_ID=$GL_ID\nexit 1")
for _, featureSet := range featureSets {
- t.Run("disabled "+featureSet.String(), func(t *testing.T) {
+ t.Run(featureSet.Desc(), func(t *testing.T) {
for _, hookName := range gitlabPreHooks {
t.Run(hookName, func(t *testing.T) {
remove, err := testhelper.WriteCustomHook(testRepoPath, hookName, hookContent)
diff --git a/internal/gitaly/service/operations/merge_test.go b/internal/gitaly/service/operations/merge_test.go
index 2a50858c9..a499701ad 100644
--- a/internal/gitaly/service/operations/merge_test.go
+++ b/internal/gitaly/service/operations/merge_test.go
@@ -33,7 +33,7 @@ func testWithFeature(t *testing.T, feature featureflag.FeatureFlag, testcase fun
})
for _, featureSet := range featureSets {
- t.Run("disabled "+featureSet.String(), func(t *testing.T) {
+ t.Run(featureSet.Desc(), func(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
@@ -321,7 +321,7 @@ func TestSuccessfulUserFFBranchRequest(t *testing.T) {
})
for _, featureSet := range featureSets {
- t.Run("disabled "+featureSet.String(), func(t *testing.T) {
+ t.Run(featureSet.Desc(), func(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
@@ -447,7 +447,7 @@ func TestFailedUserFFBranchRequest(t *testing.T) {
}
for _, featureSet := range featureSets {
- t.Run("disabled "+featureSet.String(), func(t *testing.T) {
+ t.Run(featureSet.Desc(), func(t *testing.T) {
for _, testCase := range testCases {
t.Run(testCase.desc, func(t *testing.T) {
ctx, cancel := testhelper.Context()
@@ -498,7 +498,7 @@ func TestFailedUserFFBranchDueToHooks(t *testing.T) {
})
for _, featureSet := range featureSets {
- t.Run("disabled "+featureSet.String(), func(t *testing.T) {
+ t.Run(featureSet.Desc(), func(t *testing.T) {
for _, hookName := range gitlabPreHooks {
t.Run(hookName, func(t *testing.T) {
remove, err := testhelper.WriteCustomHook(testRepoPath, hookName, hookContent)
diff --git a/internal/gitaly/service/operations/squash_test.go b/internal/gitaly/service/operations/squash_test.go
index 82d047526..64e1f007b 100644
--- a/internal/gitaly/service/operations/squash_test.go
+++ b/internal/gitaly/service/operations/squash_test.go
@@ -34,7 +34,7 @@ func TestSuccessfulUserSquashRequest(t *testing.T) {
featureSets := testhelper.NewFeatureSets([]featureflag.FeatureFlag{featureflag.GoUserSquash})
for _, featureSet := range featureSets {
- t.Run("with sparse checkout: disabled "+featureSet.String(), func(t *testing.T) {
+ t.Run("with sparse checkout: "+featureSet.Desc(), func(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
@@ -43,7 +43,7 @@ func TestSuccessfulUserSquashRequest(t *testing.T) {
testSuccessfulUserSquashRequest(t, ctx, startSha, endSha)
})
- t.Run("without sparse checkout: disabled "+featureSet.String(), func(t *testing.T) {
+ t.Run("without sparse checkout: "+featureSet.Desc(), func(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
diff --git a/internal/testhelper/featureset.go b/internal/testhelper/featureset.go
index 7cc368420..849bacd49 100644
--- a/internal/testhelper/featureset.go
+++ b/internal/testhelper/featureset.go
@@ -16,19 +16,20 @@ type FeatureSet struct {
rubyFeatures map[featureflag.FeatureFlag]struct{}
}
-func (f FeatureSet) String() string {
+// Desc describes the feature such that it is suitable as a testcase description.
+func (f FeatureSet) Desc() string {
features := make([]string, 0, len(f.features))
for feature := range f.features {
features = append(features, feature.Name)
}
if len(features) == 0 {
- return "none"
+ return "all features enabled"
}
sort.Strings(features)
- return strings.Join(features, ",")
+ return "disabled " + strings.Join(features, ",")
}
func (f FeatureSet) Disable(ctx context.Context) context.Context {