Welcome to mirror list, hosted at ThFree Co, Russian Federation.

create_test.go « bundle « git « internal - gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 14283b0c978ab7a085664eb55192bd0c31205dbb (plain)
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
package bundle

import (
	"bytes"
	"os"
	"testing"

	"github.com/stretchr/testify/require"
	"gitlab.com/gitlab-org/gitaly/internal/testhelper"
)

func TestCreateFull(t *testing.T) {
	testRepo, _, cleanup := testhelper.NewTestRepo(t)
	defer cleanup()

	ctx, cancel := testhelper.Context()
	defer cancel()

	_, err := Create(ctx, testRepo)
	require.NoError(t, err)
}

func TestCreateIncremental(t *testing.T) {
	testRepo, _, cleanup := testhelper.NewTestRepo(t)
	defer cleanup()

	ctx, cancel := testhelper.Context()
	defer cancel()

	_, err := Create(ctx, testRepo)
	require.NoError(t, err)

	b, err := Create(ctx, testRepo)
	require.NoError(t, err)

	bytes := bytes.SplitN(b, []byte("\n\n"), 2)
	require.Empty(t, bytes[1])
}

func TestUnpack(t *testing.T) {
	testRepo, _, cleanup := testhelper.NewTestRepo(t)
	defer cleanup()

	ctx, cancel := testhelper.Context()
	defer cancel()

	b, err := Create(ctx, testRepo)
	require.NoError(t, err)

	emptyRepo, emptyRepoPath, _ := testhelper.InitBareRepo(t)
	//	defer cleanup()

	t.Logf("EMPTY REPO: %v\n", emptyRepoPath)
	require.NoError(t, Unpack(ctx, emptyRepo, b))
}

func TestMain(m *testing.M) {
	testhelper.Configure()
	os.Exit(m.Run())
}