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>2021-11-18 17:30:03 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-11-18 17:46:39 +0300
commiteaacb2b39c8784e837dfa30defa2081955d9c4ce (patch)
tree78714d899bf208f334e7903dbdeefb0e5e56811c
parentb6dda5d1f7a7e05c34ed0f72f161a46aee536d75 (diff)
testhelper: Drop Ruby flags from default feature set constructor
Go-specific and Ruby-specific feature flags have different prefixes, which is why the feature set constructor accepts two lists of flags for both areas. Ruby feature flags are not currently in use by anything though, and they likely will not be for the foreseeable future. But they do make the calling convention for the feature set constructor needlessly verbose. Refactor the helper to only accept Go feature flags. A new function `NewFeatureFlagsWithRubyFlags()` is created in case we'll ever have to use Ruby feature flags.
-rw-r--r--internal/gitaly/service/commit/tree_entries_test.go4
-rw-r--r--internal/gitaly/service/ref/refs_test.go20
-rw-r--r--internal/gitaly/service/repository/license_test.go8
-rw-r--r--internal/testhelper/featureset.go11
-rw-r--r--internal/testhelper/featureset_test.go8
5 files changed, 19 insertions, 32 deletions
diff --git a/internal/gitaly/service/commit/tree_entries_test.go b/internal/gitaly/service/commit/tree_entries_test.go
index 1c952d68c..e839f0e1c 100644
--- a/internal/gitaly/service/commit/tree_entries_test.go
+++ b/internal/gitaly/service/commit/tree_entries_test.go
@@ -658,9 +658,7 @@ func drainTreeEntriesResponse(c gitalypb.CommitService_GetTreeEntriesClient) err
}
func BenchmarkGetTreeEntries(b *testing.B) {
- testhelper.NewFeatureSets([]featureflag.FeatureFlag{
- featureflag.TreeEntriesViaLsTree,
- }).Bench(b, benchmarkGetTreeEntries)
+ testhelper.NewFeatureSets(featureflag.TreeEntriesViaLsTree).Bench(b, benchmarkGetTreeEntries)
}
func benchmarkGetTreeEntries(b *testing.B, ctx context.Context) {
diff --git a/internal/gitaly/service/ref/refs_test.go b/internal/gitaly/service/ref/refs_test.go
index 02e1f74ef..001afaddc 100644
--- a/internal/gitaly/service/ref/refs_test.go
+++ b/internal/gitaly/service/ref/refs_test.go
@@ -355,9 +355,7 @@ func TestSuccessfulFindLocalBranches(t *testing.T) {
}
func TestFindLocalBranches_huge_committer(t *testing.T) {
- testhelper.NewFeatureSets([]featureflag.FeatureFlag{
- featureflag.ExactPaginationTokenMatch,
- }).Run(t, testFindLocalBranchesHugeCommitter)
+ testhelper.NewFeatureSets(featureflag.ExactPaginationTokenMatch).Run(t, testFindLocalBranchesHugeCommitter)
}
func testFindLocalBranchesHugeCommitter(t *testing.T, ctx context.Context) {
@@ -383,9 +381,7 @@ func testFindLocalBranchesHugeCommitter(t *testing.T, ctx context.Context) {
}
func TestFindLocalBranchesPagination(t *testing.T) {
- testhelper.NewFeatureSets([]featureflag.FeatureFlag{
- featureflag.ExactPaginationTokenMatch,
- }).Run(t, testFindLocalBranchesPagination)
+ testhelper.NewFeatureSets(featureflag.ExactPaginationTokenMatch).Run(t, testFindLocalBranchesPagination)
}
func testFindLocalBranchesPagination(t *testing.T, ctx context.Context) {
@@ -437,9 +433,7 @@ func testFindLocalBranchesPagination(t *testing.T, ctx context.Context) {
}
func TestFindLocalBranchesPaginationSequence(t *testing.T) {
- testhelper.NewFeatureSets([]featureflag.FeatureFlag{
- featureflag.ExactPaginationTokenMatch,
- }).Run(t, testFindLocalBranchesPaginationSequence)
+ testhelper.NewFeatureSets(featureflag.ExactPaginationTokenMatch).Run(t, testFindLocalBranchesPaginationSequence)
}
func testFindLocalBranchesPaginationSequence(t *testing.T, ctx context.Context) {
@@ -492,9 +486,7 @@ func testFindLocalBranchesPaginationSequence(t *testing.T, ctx context.Context)
}
func TestFindLocalBranchesPaginationWithIncorrectToken(t *testing.T) {
- testhelper.NewFeatureSets([]featureflag.FeatureFlag{
- featureflag.ExactPaginationTokenMatch,
- }).Run(t, testFindLocalBranchesPaginationWithIncorrectToken)
+ testhelper.NewFeatureSets(featureflag.ExactPaginationTokenMatch).Run(t, testFindLocalBranchesPaginationWithIncorrectToken)
}
func testFindLocalBranchesPaginationWithIncorrectToken(t *testing.T, ctx context.Context) {
@@ -570,9 +562,7 @@ func isOrderedSubset(subset, set []string) bool {
}
func TestFindLocalBranchesSort(t *testing.T) {
- testhelper.NewFeatureSets([]featureflag.FeatureFlag{
- featureflag.ExactPaginationTokenMatch,
- }).Run(t, testFindLocalBranchesSort)
+ testhelper.NewFeatureSets(featureflag.ExactPaginationTokenMatch).Run(t, testFindLocalBranchesSort)
}
func testFindLocalBranchesSort(t *testing.T, ctx context.Context) {
diff --git a/internal/gitaly/service/repository/license_test.go b/internal/gitaly/service/repository/license_test.go
index e784b9cb5..49dfe1c91 100644
--- a/internal/gitaly/service/repository/license_test.go
+++ b/internal/gitaly/service/repository/license_test.go
@@ -16,9 +16,7 @@ import (
)
func testSuccessfulFindLicenseRequest(t *testing.T, cfg config.Cfg, client gitalypb.RepositoryServiceClient, rubySrv *rubyserver.Server) {
- testhelper.NewFeatureSets([]featureflag.FeatureFlag{
- featureflag.GoFindLicense,
- }).Run(t, func(t *testing.T, ctx context.Context) {
+ testhelper.NewFeatureSets(featureflag.GoFindLicense).Run(t, func(t *testing.T, ctx context.Context) {
for _, tc := range []struct {
desc string
nonExistentRepository bool
@@ -108,9 +106,7 @@ SOFTWARE.`,
}
func testFindLicenseRequestEmptyRepo(t *testing.T, cfg config.Cfg, client gitalypb.RepositoryServiceClient, rubySrv *rubyserver.Server) {
- testhelper.NewFeatureSets([]featureflag.FeatureFlag{
- featureflag.GoFindLicense,
- }).Run(t, func(t *testing.T, ctx context.Context) {
+ testhelper.NewFeatureSets(featureflag.GoFindLicense).Run(t, func(t *testing.T, ctx context.Context) {
repo, repoPath := gittest.InitRepo(t, cfg, cfg.Storages[0])
require.NoError(t, os.RemoveAll(repoPath))
diff --git a/internal/testhelper/featureset.go b/internal/testhelper/featureset.go
index cb89a36af..06b794fa8 100644
--- a/internal/testhelper/featureset.go
+++ b/internal/testhelper/featureset.go
@@ -54,9 +54,14 @@ func (f FeatureSet) Disable(ctx context.Context) context.Context {
// FeatureSets is a slice containing many FeatureSets
type FeatureSets []FeatureSet
-// NewFeatureSets takes a slice of go feature flags, and an optional variadic set of ruby feature flags
-// and returns a FeatureSets slice
-func NewFeatureSets(goFeatures []featureflag.FeatureFlag, rubyFeatures ...featureflag.FeatureFlag) FeatureSets {
+// NewFeatureSets takes Go feature flags and returns the combination of FeatureSets.
+func NewFeatureSets(features ...featureflag.FeatureFlag) FeatureSets {
+ return NewFeatureSetsWithRubyFlags(features, nil)
+}
+
+// NewFeatureSetsWithRubyFlags takes a Go- and Ruby-specific feature flags and returns a the
+// combination of FeatureSets.
+func NewFeatureSetsWithRubyFlags(goFeatures []featureflag.FeatureFlag, rubyFeatures []featureflag.FeatureFlag) FeatureSets {
var sets FeatureSets
length := len(goFeatures) + len(rubyFeatures)
diff --git a/internal/testhelper/featureset_test.go b/internal/testhelper/featureset_test.go
index 2d1872203..da67acfae 100644
--- a/internal/testhelper/featureset_test.go
+++ b/internal/testhelper/featureset_test.go
@@ -23,7 +23,7 @@ func features(flag ...ff.FeatureFlag) map[ff.FeatureFlag]struct{} {
return features
}
-func TestNewFeatureSets(t *testing.T) {
+func TestNewFeatureSetsWithRubyFlags(t *testing.T) {
testcases := []struct {
desc string
features []ff.FeatureFlag
@@ -129,7 +129,7 @@ func TestNewFeatureSets(t *testing.T) {
for _, tc := range testcases {
t.Run(tc.desc, func(t *testing.T) {
- featureSets := NewFeatureSets(tc.features, tc.rubyFeatures...)
+ featureSets := NewFeatureSetsWithRubyFlags(tc.features, tc.rubyFeatures)
require.Len(t, featureSets, len(tc.expected))
for _, expected := range tc.expected {
require.Contains(t, featureSets, expected)
@@ -152,9 +152,7 @@ func TestFeatureSets_Run(t *testing.T) {
}(ff.All)
ff.All = append(ff.All, featureFlagA, featureFlagB)
- NewFeatureSets([]ff.FeatureFlag{
- featureFlagB, featureFlagA,
- }).Run(t, func(t *testing.T, ctx context.Context) {
+ NewFeatureSets(featureFlagB, featureFlagA).Run(t, func(t *testing.T, ctx context.Context) {
incomingMD, ok := grpc_metadata.FromIncomingContext(ctx)
require.True(t, ok)