-
Notifications
You must be signed in to change notification settings - Fork 0
/
dumper_test.go
45 lines (39 loc) · 1.13 KB
/
dumper_test.go
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
package dumper
import (
"io"
"os"
"path"
"path/filepath"
"testing"
"github.com/go-git/go-git/v5"
"github.com/stretchr/testify/require"
)
// dummy test
func TestNew(t *testing.T) {
dumper := New()
require.NotNil(t, dumper, "expect to have proper dumper instance")
}
func TestRepository(t *testing.T) {
tempDir := os.TempDir()
fullDestinationPath := path.Join(filepath.Clean(tempDir), destinationRepositoryDir)
dumper := New()
opts := &DumpRepositoryOptions{
RepositoryURL: testRepositoryURL,
Destination: fullDestinationPath,
OnlyDefaultBranch: PositiveBoolRef(),
Creds: Creds{
Password: "blahblah",
},
Output: &Output{
GitOutput: io.Discard,
},
}
_, err := dumper.DumpRepository(opts)
defer os.RemoveAll(fullDestinationPath)
require.NoError(t, err, "expect to properly dump repository")
// get repository by it's path
// and verify if it is returned as Repository instance
repository, err := Repository(fullDestinationPath)
require.NoError(t, err, "expect to properly get repository with no errors")
require.IsType(t, &git.Repository{}, repository, "expect to have proper repository instance")
}