-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitclone_test.go
50 lines (42 loc) · 1.11 KB
/
gitclone_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
46
47
48
49
50
package main
import (
"os"
"os/exec"
"path"
"testing"
"github.com/WindomZ/testify/assert"
)
func TestGitClone_Root(t *testing.T) {
cmd := exec.Command("gitclone", "https://github.com/WindomZ/gitclone.git")
if err := cmd.Run(); err != nil {
assert.Error(t, err)
}
_, err := os.Stat(path.Join("github.com", "WindomZ", "gitclone", ".git"))
assert.Equal(t,
err == nil || os.IsExist(err),
true,
"No file exists: './GitClones/github.com/WindomZ/gitclone/.git'",
)
}
func TestGitClone_Root_Depth(t *testing.T) {
cmd := exec.Command("gitclone", "https://github.com/WindomZ/gitclone.git", "--depth", "2")
if err := cmd.Run(); err != nil {
assert.Error(t, err)
}
_, err := os.Stat(path.Join("WindomZ", "gitclone", ".git"))
assert.Equal(t,
err == nil || os.IsExist(err),
true,
"No file exists: './GitClones/github.com/WindomZ/gitclone/.git'",
)
}
func TestGitClone_Clean(t *testing.T) {
cmd := exec.Command("rm", "-rf", "github.com")
if err := cmd.Run(); err != nil {
assert.Error(t, err)
}
cmd = exec.Command("rm", "-rf", "WindomZ")
if err := cmd.Run(); err != nil {
assert.Error(t, err)
}
}