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
56
57
58
59
60
61
62
63
|
package housekeeping
import (
"testing"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v15/internal/git/gittest"
"gitlab.com/gitlab-org/gitaly/v15/internal/praefect/praefectutil"
"gitlab.com/gitlab-org/gitaly/v15/proto/go/gitalypb"
)
func TestIsPoolRepository(t *testing.T) {
t.Parallel()
for _, tc := range []struct {
desc string
repo *gitalypb.Repository
isPoolPath bool
}{
{
desc: "rails pool directory",
repo: &gitalypb.Repository{
RelativePath: gittest.NewObjectPoolName(t),
},
isPoolPath: true,
},
{
desc: "praefect pool path",
repo: &gitalypb.Repository{
RelativePath: praefectutil.DerivePoolPath(1),
},
isPoolPath: true,
},
{
desc: "praefect replica path",
repo: &gitalypb.Repository{
RelativePath: praefectutil.DeriveReplicaPath(1),
},
},
{
desc: "missing repository",
},
{
desc: "empty repository",
repo: &gitalypb.Repository{},
},
{
desc: "rails path first to subdirs dont match full hash",
repo: &gitalypb.Repository{
RelativePath: "@pools/aa/bb/ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff.git",
},
},
{
desc: "normal repos dont match",
repo: &gitalypb.Repository{
RelativePath: "@hashed/" + gittest.NewRepositoryName(t),
},
},
} {
t.Run(tc.desc, func(t *testing.T) {
require.Equal(t, tc.isPoolPath, IsPoolRepository(tc.repo))
})
}
}
|