File: config_test.go

package info (click to toggle)
gitbatch 0.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 644 kB
  • sloc: makefile: 5; sh: 1
file content (79 lines) | stat: -rw-r--r-- 1,654 bytes parent folder | download
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
72
73
74
75
76
77
78
79
package command

import (
	"testing"

	"github.com/isacikgoz/gitbatch/internal/git"
	"github.com/stretchr/testify/require"
)

func TestConfigWithGit(t *testing.T) {
	th := git.InitTestRepositoryFromLocal(t)
	defer th.CleanUp(t)

	testConfigopt := &ConfigOptions{
		Section: "remote.origin",
		Option:  "url",
		Site:    ConfigSiteLocal,
	}

	var tests = []struct {
		inp1     *git.Repository
		inp2     *ConfigOptions
		expected string
	}{
		{th.Repository, testConfigopt, "https://gitlab.com/isacikgoz/test-data.git"},
	}
	for _, test := range tests {
		output, err := configWithGit(test.inp1, test.inp2)
		require.NoError(t, err)
		require.Equal(t, test.expected, output)
	}
}

func TestConfigWithGoGit(t *testing.T) {
	th := git.InitTestRepositoryFromLocal(t)
	defer th.CleanUp(t)

	testConfigopt := &ConfigOptions{
		Section: "core",
		Option:  "bare",
		Site:    ConfigSiteLocal,
	}

	var tests = []struct {
		inp1     *git.Repository
		inp2     *ConfigOptions
		expected string
	}{
		{th.Repository, testConfigopt, "false"},
	}
	for _, test := range tests {
		output, err := configWithGoGit(test.inp1, test.inp2)
		require.NoError(t, err)
		require.Equal(t, output, test.expected)
	}
}

func TestAddConfigWithGit(t *testing.T) {
	th := git.InitTestRepositoryFromLocal(t)
	defer th.CleanUp(t)

	testConfigopt := &ConfigOptions{
		Section: "user",
		Option:  "name",
		Site:    ConfigSiteLocal,
	}

	var tests = []struct {
		inp1 *git.Repository
		inp2 *ConfigOptions
		inp3 string
	}{
		{th.Repository, testConfigopt, "foo"},
	}
	for _, test := range tests {
		err := addConfigWithGit(test.inp1, test.inp2, test.inp3)
		require.NoError(t, err)
	}
}