[gitfame] Add tests.
This commit is contained in:
parent
d9af0a8118
commit
c7486767c2
53 changed files with 90 additions and 4 deletions
|
@ -33,7 +33,7 @@ func TestGitFame(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
bundlesDir := path.Join("./testdata", "bundles")
|
||||
testsDir := path.Join("./testdata", "good")
|
||||
testsDir := path.Join("./testdata", "tests")
|
||||
files, err := ioutil.ReadDir(testsDir)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
@ -58,9 +58,14 @@ func TestGitFame(t *testing.T) {
|
|||
cmd.Stderr = ioutil.Discard
|
||||
|
||||
output, err := cmd.Output()
|
||||
if !tc.Error {
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, string(tc.Expected), string(output))
|
||||
} else {
|
||||
require.Error(t, err)
|
||||
_, ok := err.(*exec.ExitError)
|
||||
require.True(t, ok)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -85,6 +90,7 @@ type TestDescription struct {
|
|||
Name string `yaml:"name"`
|
||||
Args []string `yaml:"args"`
|
||||
Bundle string `yaml:"bundle"`
|
||||
Error bool `yaml:"error"`
|
||||
}
|
||||
|
||||
func ReadTestDescription(t *testing.T, path string) *TestDescription {
|
||||
|
|
5
gitfame/test/integration/testdata/tests/19/description.yaml
vendored
Normal file
5
gitfame/test/integration/testdata/tests/19/description.yaml
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
# go-cmp, HEAD, extensions
|
||||
|
||||
name: go-cmp HEAD extensions
|
||||
args: [--format, csv, --extensions, '.yml,.json,.md']
|
||||
bundle: go-cmp.bundle
|
5
gitfame/test/integration/testdata/tests/19/expected.out
vendored
Normal file
5
gitfame/test/integration/testdata/tests/19/expected.out
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
Name,Lines,Commits,Files
|
||||
Joe Tsai,92,4,3
|
||||
Ross Light,2,1,1
|
||||
Tobias Klauser,2,1,1
|
||||
ferhat elmas,1,1,1
|
5
gitfame/test/integration/testdata/tests/20/description.yaml
vendored
Normal file
5
gitfame/test/integration/testdata/tests/20/description.yaml
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
# go-cmp, HEAD, languages
|
||||
|
||||
name: go-cmp HEAD languages
|
||||
args: [--format, csv, --languages, 'yaml,c++,markdown,gopher']
|
||||
bundle: go-cmp.bundle
|
5
gitfame/test/integration/testdata/tests/20/expected.out
vendored
Normal file
5
gitfame/test/integration/testdata/tests/20/expected.out
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
Name,Lines,Commits,Files
|
||||
Joe Tsai,92,4,3
|
||||
Ross Light,2,1,1
|
||||
Tobias Klauser,2,1,1
|
||||
ferhat elmas,1,1,1
|
5
gitfame/test/integration/testdata/tests/21/description.yaml
vendored
Normal file
5
gitfame/test/integration/testdata/tests/21/description.yaml
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
# go-cmp, HEAD, exclude
|
||||
|
||||
name: go-cmp HEAD exclude
|
||||
args: [--format, csv, --exclude, 'cmp/cmpopts/*,cmp/internal/testprotos/*,cmp/testdata/*,gopher/*']
|
||||
bundle: go-cmp.bundle
|
14
gitfame/test/integration/testdata/tests/21/expected.out
vendored
Normal file
14
gitfame/test/integration/testdata/tests/21/expected.out
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
Name,Lines,Commits,Files
|
||||
Joe Tsai,10087,90,46
|
||||
A. Ishikawa,36,1,1
|
||||
178inaba,11,2,4
|
||||
Kyle Lemons,11,1,1
|
||||
Christian Muehlhaeuser,4,3,3
|
||||
Ernest Galbrun,3,1,1
|
||||
ferhat elmas,2,1,2
|
||||
Dmitri Shuralyov,2,1,1
|
||||
Ross Light,2,1,1
|
||||
Tobias Klauser,2,1,1
|
||||
Chris Morrow,1,1,1
|
||||
Fiisio,1,1,1
|
||||
LMMilewski,1,1,1
|
5
gitfame/test/integration/testdata/tests/22/description.yaml
vendored
Normal file
5
gitfame/test/integration/testdata/tests/22/description.yaml
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
# go-cmp, HEAD, restrict to
|
||||
|
||||
name: go-cmp HEAD restrict-to
|
||||
args: [--format, csv, --restrict-to, 'cmp/cmpopts/*,cmp/internal/testprotos/*,cmp/testdata/*,gopher/*']
|
||||
bundle: go-cmp.bundle
|
12
gitfame/test/integration/testdata/tests/22/expected.out
vendored
Normal file
12
gitfame/test/integration/testdata/tests/22/expected.out
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
Name,Lines,Commits,Files
|
||||
Joe Tsai,3731,29,8
|
||||
colinnewell,130,1,1
|
||||
Roger Peppe,59,1,2
|
||||
A. Ishikawa,56,1,1
|
||||
Tobias Klauser,33,1,2
|
||||
178inaba,16,1,1
|
||||
Dmitri Shuralyov,6,1,1
|
||||
k.nakada,5,1,3
|
||||
ferhat elmas,5,1,2
|
||||
LMMilewski,4,1,1
|
||||
Christian Muehlhaeuser,2,1,1
|
5
gitfame/test/integration/testdata/tests/23/description.yaml
vendored
Normal file
5
gitfame/test/integration/testdata/tests/23/description.yaml
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
# go-cmp, HEAD, exclude and restrict to the same dir
|
||||
|
||||
name: go-cmp HEAD exclude restrict-to
|
||||
args: [--format, csv, --restrict-to, 'cmp/cmpopts/*', --exclude, 'cmp/cmpopts/*']
|
||||
bundle: go-cmp.bundle
|
6
gitfame/test/integration/testdata/tests/24/description.yaml
vendored
Normal file
6
gitfame/test/integration/testdata/tests/24/description.yaml
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
# bad format
|
||||
|
||||
name: bad format
|
||||
args: [--format, yson, --revision, v1.0]
|
||||
bundle: simple.bundle
|
||||
error: true
|
0
gitfame/test/integration/testdata/tests/24/expected.out
vendored
Normal file
0
gitfame/test/integration/testdata/tests/24/expected.out
vendored
Normal file
6
gitfame/test/integration/testdata/tests/25/description.yaml
vendored
Normal file
6
gitfame/test/integration/testdata/tests/25/description.yaml
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
# bad sort order
|
||||
|
||||
name: bad sort oder
|
||||
args: [--order-by, time, --revision, v1.0]
|
||||
bundle: simple.bundle
|
||||
error: true
|
0
gitfame/test/integration/testdata/tests/25/expected.out
vendored
Normal file
0
gitfame/test/integration/testdata/tests/25/expected.out
vendored
Normal file
6
gitfame/test/integration/testdata/tests/26/description.yaml
vendored
Normal file
6
gitfame/test/integration/testdata/tests/26/description.yaml
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
# bad revision
|
||||
|
||||
name: bad revision
|
||||
args: [--revision, head]
|
||||
bundle: simple.bundle
|
||||
error: true
|
0
gitfame/test/integration/testdata/tests/26/expected.out
vendored
Normal file
0
gitfame/test/integration/testdata/tests/26/expected.out
vendored
Normal file
1
gitfame/test/integration/testdata/tests/6/expected.out
vendored
Normal file
1
gitfame/test/integration/testdata/tests/6/expected.out
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
Name,Lines,Commits,Files
|
Loading…
Reference in a new issue