mirror of
https://github.com/grdl/git-get.git
synced 2026-02-06 02:57:56 +00:00
Add test parallelization and re-enable paralleltest linter
This commit is contained in:
@@ -21,6 +21,7 @@ func (c *cfgStub) Get(key string) string {
|
||||
}
|
||||
|
||||
func TestGitConfig(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
name string
|
||||
configMaker func(t *testing.T) *cfgStub
|
||||
@@ -53,6 +54,7 @@ func TestGitConfig(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
cfg := test.configMaker(t)
|
||||
|
||||
got := cfg.Get(test.key)
|
||||
|
||||
@@ -9,6 +9,8 @@ import (
|
||||
)
|
||||
|
||||
func TestFinder(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
reposMaker func(*testing.T) string
|
||||
@@ -31,6 +33,7 @@ func TestFinder(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
root := test.reposMaker(t)
|
||||
|
||||
finder := NewRepoFinder(root)
|
||||
@@ -46,6 +49,8 @@ func TestFinder(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExists(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
path string
|
||||
@@ -64,6 +69,8 @@ func TestExists(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
_, err := Exists(test.path)
|
||||
|
||||
assert.ErrorIs(t, err, test.want)
|
||||
|
||||
@@ -157,8 +157,7 @@ func (r *Repo) Branches() ([]string, error) {
|
||||
func (r *Repo) Upstream(branch string) (string, error) {
|
||||
out, err := run.Git("rev-parse", "--abbrev-ref", "--symbolic-full-name", branch+"@{upstream}").OnRepo(r.path).AndCaptureLine()
|
||||
if err != nil {
|
||||
// TODO: no upstream will also throw an error.
|
||||
// lint:ignore nilerr fix when working on TODO
|
||||
//nolint:nilerr // TODO: no upstream will also throw an error.
|
||||
return "", nil
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ import (
|
||||
)
|
||||
|
||||
func TestUncommitted(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
repoMaker func(*testing.T) *test.Repo
|
||||
@@ -46,6 +48,7 @@ func TestUncommitted(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
r, _ := Open(test.repoMaker(t).Path())
|
||||
|
||||
got, err := r.Uncommitted()
|
||||
@@ -60,6 +63,8 @@ func TestUncommitted(t *testing.T) {
|
||||
}
|
||||
}
|
||||
func TestUntracked(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
repoMaker func(*testing.T) *test.Repo
|
||||
@@ -94,6 +99,7 @@ func TestUntracked(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
r, _ := Open(test.repoMaker(t).Path())
|
||||
|
||||
got, err := r.Untracked()
|
||||
@@ -109,6 +115,8 @@ func TestUntracked(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCurrentBranch(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
repoMaker func(*testing.T) *test.Repo
|
||||
@@ -133,6 +141,7 @@ func TestCurrentBranch(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
r, _ := Open(test.repoMaker(t).Path())
|
||||
|
||||
got, err := r.CurrentBranch()
|
||||
@@ -147,6 +156,8 @@ func TestCurrentBranch(t *testing.T) {
|
||||
}
|
||||
}
|
||||
func TestBranches(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
repoMaker func(*testing.T) *test.Repo
|
||||
@@ -176,6 +187,7 @@ func TestBranches(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
r, _ := Open(test.repoMaker(t).Path())
|
||||
|
||||
got, err := r.Branches()
|
||||
@@ -190,6 +202,8 @@ func TestBranches(t *testing.T) {
|
||||
}
|
||||
}
|
||||
func TestUpstream(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
repoMaker func(*testing.T) *test.Repo
|
||||
@@ -231,6 +245,7 @@ func TestUpstream(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
r, _ := Open(test.repoMaker(t).Path())
|
||||
got, _ := r.Upstream(test.branch)
|
||||
|
||||
@@ -246,6 +261,8 @@ func TestUpstream(t *testing.T) {
|
||||
}
|
||||
}
|
||||
func TestAheadBehind(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
repoMaker func(*testing.T) *test.Repo
|
||||
@@ -281,6 +298,7 @@ func TestAheadBehind(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
r, _ := Open(test.repoMaker(t).Path())
|
||||
|
||||
upstream, err := r.Upstream(test.branch)
|
||||
@@ -301,6 +319,7 @@ func TestAheadBehind(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCleanupFailedClone(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Test dir structure:
|
||||
// root
|
||||
// └── a/
|
||||
@@ -335,6 +354,7 @@ func TestCleanupFailedClone(t *testing.T) {
|
||||
|
||||
for i, test := range tests {
|
||||
t.Run(strconv.Itoa(i), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
root := createTestDirTree(t)
|
||||
|
||||
path := filepath.Join(root, test.path)
|
||||
@@ -354,6 +374,8 @@ func TestCleanupFailedClone(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemote(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
repoMaker func(*testing.T) *test.Repo
|
||||
@@ -382,6 +404,7 @@ func TestRemote(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
r, _ := Open(test.repoMaker(t).Path())
|
||||
got, err := r.Remote()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user