1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
package hook
import (
"testing"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/internal/backchannel"
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/hook"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/internal/gitlab"
"gitlab.com/gitlab-org/gitaly/internal/streamcache"
)
func isNullCache(c streamcache.Cache) bool {
_, ok := c.(streamcache.NullCache)
return ok
}
func TestNewServer(t *testing.T) {
testCases := []struct {
desc string
cfg config.Cfg
nullCache bool
}{
{
desc: "cache disabled",
nullCache: true,
},
{
desc: "cache enabled",
cfg: config.Cfg{
PackObjectsCache: config.PackObjectsCache{
Enabled: true,
},
},
nullCache: false,
},
}
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
cfg := tc.cfg
poc := NewServer(
cfg,
hook.NewManager(config.NewLocator(cfg), transaction.NewManager(cfg, backchannel.NewRegistry()), gitlab.NewMockClient(), cfg),
git.NewExecCommandFactory(cfg),
).(*server).packObjectsCache
require.NotNil(t, poc)
require.Equal(t, tc.nullCache, isNullCache(poc))
})
}
}
|