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
|
package load
import (
"fmt"
"testing"
"github.com/isacikgoz/gitbatch/internal/git"
"github.com/stretchr/testify/require"
)
func TestSyncLoad(t *testing.T) {
th := git.InitTestRepositoryFromLocal(t)
defer th.CleanUp(t)
var tests = []struct {
input []string
}{
{[]string{th.BasicRepoPath(), th.DirtyRepoPath()}},
}
for _, test := range tests {
output, err := SyncLoad(test.input)
require.NoError(t, err)
require.NotEmpty(t, output)
}
}
func TestAsyncLoad(t *testing.T) {
th := git.InitTestRepositoryFromLocal(t)
defer th.CleanUp(t)
testChannel := make(chan bool)
testAsyncMockFunc := func(r *git.Repository) {
go func() {
if <-testChannel {
fmt.Println(r.Name)
}
}()
}
var tests = []struct {
inp1 []string
inp2 AsyncAdd
inp3 chan bool
}{
{[]string{th.BasicRepoPath(), th.DirtyRepoPath()}, testAsyncMockFunc, testChannel},
}
for _, test := range tests {
err := AsyncLoad(test.inp1, test.inp2, test.inp3)
require.NoError(t, err)
}
}
|