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

command_description_test.go « git « internal - gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 574fa5592c0e10e21c9c5baa1664e1b0dd0f044a (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
61
62
63
64
65
66
67
68
69
70
71
//go:build !gitaly_test_sha256

package git

import (
	"fmt"
	"testing"

	"github.com/stretchr/testify/require"
)

func TestCommandDescriptions_revListPositionalArgs(t *testing.T) {
	revlist, ok := commandDescriptions["rev-list"]
	require.True(t, ok)
	require.NotNil(t, revlist.validatePositionalArgs)

	for _, tc := range []struct {
		desc        string
		args        []string
		expectedErr error
	}{
		{
			desc: "normal reference",
			args: []string{
				"master",
			},
		},
		{
			desc: "reference with leading dash",
			args: []string{
				"-master",
			},
			expectedErr: fmt.Errorf("rev-list: %w",
				fmt.Errorf("positional arg \"-master\" cannot start with dash '-': %w", ErrInvalidArg),
			),
		},
		{
			desc: "revisions and pseudo-revisions",
			args: []string{
				"master --not --all",
			},
		},
	} {
		t.Run(tc.desc, func(t *testing.T) {
			err := revlist.validatePositionalArgs(tc.args)
			require.Equal(t, tc.expectedErr, err)
		})
	}
}

func TestThreadsConfigValue(t *testing.T) {
	t.Parallel()
	for _, tt := range []struct {
		cpus    int
		threads string
	}{
		{1, "1"},
		{2, "1"},
		{3, "1"},
		{4, "2"},
		{8, "3"},
		{9, "3"},
		{13, "3"},
		{16, "4"},
		{27, "4"},
		{32, "5"},
	} {
		actualThreads := threadsConfigValue(tt.cpus)
		require.Equal(t, tt.threads, actualThreads)
	}
}