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>2022-01-26 13:59:49 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-01-27 16:08:15 +0300
commit086273bb41d8a30ce84ba08b05347bf911e2367f (patch)
tree07175ce37551eab85cd4a518e2fd369b3812c1ae
parentb7f0c0462a8f689c8ee9e654f0875157b238158b (diff)
housekeeping: Rewrite config cleanup test to be more thorough
Our testcase verifying that we unset certain config entries contains quite a bunch of logic, but test logic itself is broken. As a result, we did not catch that we do not unset "remote.*.prune" keys correctly. Refactor the test to be more direct. Instead of playing tricks with executing git-config(1) we write our own gitconfig and then verify that it's got the expected state after having performed housekeeping. This also shows that we incorrectly retain above config key.
-rw-r--r--internal/git/housekeeping/housekeeping_test.go73
1 files changed, 40 insertions, 33 deletions
diff --git a/internal/git/housekeeping/housekeeping_test.go b/internal/git/housekeeping/housekeeping_test.go
index 88b00ef7e..c89dec504 100644
--- a/internal/git/housekeeping/housekeeping_test.go
+++ b/internal/git/housekeeping/housekeeping_test.go
@@ -6,7 +6,6 @@ import (
"os"
"path/filepath"
"runtime"
- "strings"
"testing"
"time"
@@ -657,42 +656,50 @@ func TestPerform_UnsetConfiguration(t *testing.T) {
cfg := testcfg.Build(t)
repoProto, repoPath := gittest.InitRepo(t, cfg, cfg.Storages[0])
repo := localrepo.NewTestRepo(t, cfg, repoProto)
- ctx := testhelper.Context(t)
+ configPath := filepath.Join(repoPath, "config")
- var expectedEntries []string
- for key, value := range map[string]string{
- "core.commitgraph": "true",
- "core.sparsecheckout": "true",
- "core.splitindex": "false",
- "remote.first.fetch": "baz",
- "remote.first.mirror": "baz",
- "remote.first.prune": "baz",
- "remote.first.url": "baz",
- "http.first.extraHeader": "barfoo",
- "http.second.extraHeader": "barfoo",
- "http.extraHeader": "untouched",
- "http.something.else": "untouched",
- "totally.unrelated": "untouched",
- } {
- gittest.Exec(t, cfg, "-C", repoPath, "config", key, value)
- expectedEntries = append(expectedEntries, strings.ToLower(key)+"="+value)
- }
+ ctx := testhelper.Context(t)
- preimageConfig := gittest.Exec(t, cfg, "-C", repoPath, "config", "--local", "--list")
- require.Subset(t, strings.Split(string(preimageConfig), "\n"), expectedEntries)
+ require.NoError(t, os.WriteFile(configPath, []byte(
+ `[core]
+ repositoryformatversion = 0
+ filemode = true
+ bare = true
+ commitGraph = true
+ sparseCheckout = true
+ splitIndex = false
+[remote "first"]
+ fetch = baz
+ mirror = baz
+ prune = baz
+ url = baz
+[http "first"]
+ extraHeader = barfoo
+[http "second"]
+ extraHeader = barfoo
+[http]
+ extraHeader = untouched
+[http "something"]
+ else = untouched
+[totally]
+ unrelated = untouched
+`), 0o644))
require.NoError(t, Perform(ctx, repo, nil))
-
- postimageConfig := gittest.Exec(t, cfg, "-C", repoPath, "config", "--local", "--list")
- require.NotContains(t, strings.Split(string(postimageConfig), "\n"), "core.commitgraph")
- require.NotContains(t, strings.Split(string(postimageConfig), "\n"), "core.sparsecheckout")
- require.NotContains(t, strings.Split(string(postimageConfig), "\n"), "core.splitindex")
- require.NotContains(t, strings.Split(string(postimageConfig), "\n"), "remote.first.fetch")
- require.NotContains(t, strings.Split(string(postimageConfig), "\n"), "remote.first.mirror")
- require.NotContains(t, strings.Split(string(postimageConfig), "\n"), "remote.first.prune")
- require.NotContains(t, strings.Split(string(postimageConfig), "\n"), "remote.first.url")
- require.NotContains(t, strings.Split(string(postimageConfig), "\n"), "http.first.extraheader")
- require.NotContains(t, strings.Split(string(postimageConfig), "\n"), "http.second.extraheader")
+ require.Equal(t,
+ `[core]
+ repositoryformatversion = 0
+ filemode = true
+ bare = true
+[remote "first"]
+ prune = baz
+[http]
+ extraHeader = untouched
+[http "something"]
+ else = untouched
+[totally]
+ unrelated = untouched
+`, string(testhelper.MustReadFile(t, configPath)))
}
func TestPerform_UnsetConfiguration_transactional(t *testing.T) {