Debian Codegraph @

internal/load/load_test.go

raw symbols SCIP
1 package load
2
3 import (
4 "fmt"
5 "testing"
6
7 "github.com/isacikgoz/gitbatch/internal/git"
8 "github.com/stretchr/testify/require"
9 )
10
11 func TestSyncLoad(t *testing.T) {
12 th := git.InitTestRepositoryFromLocal(t)
13 defer th.CleanUp(t)
14
15 var tests = []struct {
16 input []string
17 }{
18 {[]string{th.BasicRepoPath(), th.DirtyRepoPath()}},
19 }
20 for _, test := range tests {
21 output, err := SyncLoad(test.input)
22 require.NoError(t, err)
23 require.NotEmpty(t, output)
24 }
25 }
26
27 func TestAsyncLoad(t *testing.T) {
28 th := git.InitTestRepositoryFromLocal(t)
29 defer th.CleanUp(t)
30
31 testChannel := make(chan bool)
32 testAsyncMockFunc := func(r *git.Repository) {
33 go func() {
34 if <-testChannel {
35 fmt.Println(r.Name)
36 }
37 }()
38 }
39
40 var tests = []struct {
41 inp1 []string
42 inp2 AsyncAdd
43 inp3 chan bool
44 }{
45 {[]string{th.BasicRepoPath(), th.DirtyRepoPath()}, testAsyncMockFunc, testChannel},
46 }
47 for _, test := range tests {
48 err := AsyncLoad(test.inp1, test.inp2, test.inp3)
49 require.NoError(t, err)
50 }
51 }