Debian Codegraph @

internal/command/fetch_test.go

raw symbols ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 package command
2
3 import (
4 "testing"
5
6 "github.com/isacikgoz/gitbatch/internal/git"
7 "github.com/stretchr/testify/require"
8 )
9
10 var (
11 testFetchopts1 = &FetchOptions{
12 RemoteName: "origin",
13 }
14
15 testFetchopts2 = &FetchOptions{
16 RemoteName: "origin",
17 Prune: true,
18 }
19
20 testFetchopts3 = &FetchOptions{
21 RemoteName: "origin",
22 DryRun: true,
23 }
24
25 testFetchopts4 = &FetchOptions{
26 RemoteName: "origin",
27 Progress: true,
28 }
29 )
30
31 func TestFetchWithGit(t *testing.T) {
32 th := git.InitTestRepositoryFromLocal(t)
33 defer th.CleanUp(t)
34
35 var tests = []struct {
36 inp1 *git.Repository
37 inp2 *FetchOptions
38 }{
39 {th.Repository, testFetchopts1},
40 {th.Repository, testFetchopts2},
41 {th.Repository, testFetchopts3},
42 }
43 for _, test := range tests {
44 err := fetchWithGit(test.inp1, test.inp2)
45 require.NoError(t, err)
46 }
47 }
48
49 func TestFetchWithGoGit(t *testing.T) {
50 th := git.InitTestRepositoryFromLocal(t)
51 defer th.CleanUp(t)
52
53 refspec := "+" + "refs/heads/" + th.Repository.State.Branch.Name + ":" + "/refs/remotes/" + th.Repository.State.Branch.Name
54 var tests = []struct {
55 inp1 *git.Repository
56 inp2 *FetchOptions
57 inp3 string
58 }{
59 {th.Repository, testFetchopts1, refspec},
60 {th.Repository, testFetchopts4, refspec},
61 }
62 for _, test := range tests {
63 err := fetchWithGoGit(test.inp1, test.inp2, test.inp3)
64 require.NoError(t, err)
65 }
66 }