diff options
author | Pavlo Strokov <pstrokov@gitlab.com> | 2021-04-19 10:28:23 +0300 |
---|---|---|
committer | Pavlo Strokov <pstrokov@gitlab.com> | 2021-04-19 10:28:23 +0300 |
commit | 4b22c0fec0b88fb534fed609c2d465ee552fe9f0 (patch) | |
tree | d404f5d154357aa394e7381d8f9fc5fd539b9193 | |
parent | f5c607b1ea9a59c35ae47b6b03bdf98ea183a379 (diff) |
Remove config.Config from tempdir package
Usage of the global config.Config variable replaced with the
locally created value.
The order of the calls changed in the TestCleanTempDir test
as it started to create additional log entry about git
binary used for the test, because configuration of that happen
after log level change. By switching the order the old log
level is used to write that additional message and we have a
new level for the cleanTempDir function call.
Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/2699
-rw-r--r-- | internal/tempdir/tempdir_test.go | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/internal/tempdir/tempdir_test.go b/internal/tempdir/tempdir_test.go index fef06b361..4342e724e 100644 --- a/internal/tempdir/tempdir_test.go +++ b/internal/tempdir/tempdir_test.go @@ -13,6 +13,7 @@ import ( "gitlab.com/gitlab-org/gitaly/internal/git/gittest" "gitlab.com/gitlab-org/gitaly/internal/gitaly/config" "gitlab.com/gitlab-org/gitaly/internal/testhelper" + "gitlab.com/gitlab-org/gitaly/internal/testhelper/testcfg" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" ) @@ -20,10 +21,8 @@ func TestNewAsRepositorySuccess(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - repo, _, cleanup := gittest.CloneRepo(t) - defer cleanup() - - locator := config.NewLocator(config.Config) + cfg, repo, _ := testcfg.BuildWithRepo(t) + locator := config.NewLocator(cfg) tempRepo, tempDir, err := NewAsRepository(ctx, repo, locator) require.NoError(t, err) require.NotEqual(t, repo, tempRepo) @@ -104,19 +103,17 @@ func TestCleanSuccess(t *testing.T) { } func TestCleanTempDir(t *testing.T) { + cfg := testcfg.Build(t, testcfg.WithStorages("first", "second")) + gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + logrus.SetLevel(logrus.InfoLevel) logrus.SetOutput(ioutil.Discard) hook := test.NewGlobal() - storages := append(config.Config.Storages[:], config.Storage{ - Name: "default", - Path: "testdata/clean", - }) - - cleanTempDir(storages) + cleanTempDir(cfg.Storages) - require.Equal(t, 2, len(hook.Entries)) + require.Equal(t, 2, len(hook.Entries), hook.Entries) require.Equal(t, "finished tempdir cleaner walk", hook.LastEntry().Message) } |