-
Notifications
You must be signed in to change notification settings - Fork 52
/
git_command_test.go
32 lines (26 loc) · 1.27 KB
/
git_command_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
package gitkit
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestParseGitCommand(t *testing.T) {
examples := map[string]GitCommand{
"git-upload-pack 'hello.git'": {"git-upload-pack", "hello.git", "git-upload-pack 'hello.git'"},
"git upload-pack 'hello.git'": {"git upload-pack", "hello.git", "git upload-pack 'hello.git'"},
"git-upload-pack '/hello.git'": {"git-upload-pack", "hello.git", "git-upload-pack 'hello.git'"},
"git-upload-pack '/hello/world.git'": {"git-upload-pack", "hello/world.git", "git-upload-pack 'hello.git'"},
"git-receive-pack 'hello.git'": {"git-receive-pack", "hello.git", "git-receive-pack 'hello.git'"},
"git receive-pack 'hello.git'": {"git receive-pack", "hello.git", "git receive-pack 'hello.git'"},
"git-upload-archive 'hello.git'": {"git-upload-archive", "hello.git", "git-upload-archive 'hello.git'"},
"git upload-archive 'hello.git'": {"git upload-archive", "hello.git", "git upload-archive 'hello.git'"},
}
for s, expected := range examples {
cmd, err := ParseGitCommand(s)
assert.NoError(t, err)
assert.Equal(t, expected.Command, cmd.Command)
assert.Equal(t, expected.Repo, cmd.Repo)
}
cmd, err := ParseGitCommand("git do-stuff")
assert.Error(t, err)
assert.Nil(t, cmd)
}