Skip to content

Commit

Permalink
Switch tests to use alecthomas/assert/v2
Browse files Browse the repository at this point in the history
  • Loading branch information
halostatue committed Sep 21, 2023
1 parent c16b8dd commit 6d7a64e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 47 deletions.
21 changes: 6 additions & 15 deletions internal/chezmoi/findexecutable_darwin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package chezmoi
import (
"fmt"
"testing"

"github.com/alecthomas/assert/v2"
)

func TestFindExecutableOneNeedle(t *testing.T) {
Expand Down Expand Up @@ -32,13 +34,8 @@ func TestFindExecutableOneNeedle(t *testing.T) {
name := fmt.Sprintf("FindExecutable %v in %#v as %v", test.file, test.paths, test.expected)
t.Run(name, func(t *testing.T) {
actual, err := FindExecutable(test.file, test.paths)
if err != nil {
t.Errorf("FindExecutable() error = %v, expected = nil", err)
}

if actual != test.expected {
t.Errorf("FindExecutable() actual = %v, expected = %v", actual, test.expected)
}
assert.NoError(t, err)
assert.Equal(t, test.expected, actual)
})
}
}
Expand Down Expand Up @@ -75,14 +72,8 @@ func TestFindExecutableMultipleNeedles(t *testing.T) {
)
t.Run(name, func(t *testing.T) {
actual, err := FindExecutable(test.files, test.paths)
if err != nil {
t.Errorf("FindExecutable() error = %v, expected = nil", err)
return
}

if actual != test.expected {
t.Errorf("FindExecutable() actual = %v, expected = %v", actual, test.expected)
}
assert.NoError(t, err)
assert.Equal(t, test.expected, actual)
})
}
}
22 changes: 6 additions & 16 deletions internal/chezmoi/findexecutable_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package chezmoi
import (
"fmt"
"testing"

"github.com/alecthomas/assert/v2"
)

func TestFindExecutableOneNeedle(t *testing.T) {
Expand Down Expand Up @@ -34,14 +36,8 @@ func TestFindExecutableOneNeedle(t *testing.T) {
name := fmt.Sprintf("FindExecutable %v in %#v as %v", test.file, test.paths, test.expected)
t.Run(name, func(t *testing.T) {
actual, err := FindExecutable(test.file, test.paths)
if err != nil {
t.Errorf("FindExecutable() error = %v, expected = nil", err)
return
}

if actual != test.expected {
t.Errorf("FindExecutable() actual = %v, expected = %v", actual, test.expected)
}
assert.NoError(t, err)
assert.Equal(t, test.expected, actual)
})
}
}
Expand Down Expand Up @@ -78,14 +74,8 @@ func TestFindExecutableMultipleNeedles(t *testing.T) {
)
t.Run(name, func(t *testing.T) {
actual, err := FindExecutable(test.files, test.paths)
if err != nil {
t.Errorf("FindExecutable() error = %v, expected = nil", err)
return
}

if actual != test.expected {
t.Errorf("FindExecutable() actual = %v, expected = %v", actual, test.expected)
}
assert.NoError(t, err)
assert.Equal(t, test.expected, actual)
})
}
}
22 changes: 6 additions & 16 deletions internal/chezmoi/findexecutable_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"fmt"
"strings"
"testing"

"github.com/alecthomas/assert/v2"
)

func TestFindExecutableOneNeedle(t *testing.T) {
Expand Down Expand Up @@ -56,14 +58,8 @@ func TestFindExecutableOneNeedle(t *testing.T) {
name := fmt.Sprintf("FindExecutable %v in %#v as %v", test.file, test.paths, test.expected)
t.Run(name, func(t *testing.T) {
actual, err := FindExecutable(test.file, test.paths)
if err != nil {
t.Errorf("FindExecutable() error = %v, expected = nil", err)
return
}

if !strings.EqualFold(actual, test.expected) {
t.Errorf("FindExecutable() actual = %v, expected = %v", actual, test.expected)
}
assert.NoError(t, err)
assert.Equal(t, strings.ToLower(test.expected), strings.ToLower(actual))
})
}
}
Expand Down Expand Up @@ -116,14 +112,8 @@ func TestFindExecutableMultipleNeedles(t *testing.T) {
name := fmt.Sprintf("FindExecutable %v in %#v as %v", test.file, test.paths, test.expected)
t.Run(name, func(t *testing.T) {
actual, err := FindExecutable(test.file, test.paths)
if err != nil {
t.Errorf("FindExecutable() error = %v, expected = nil", err)
return
}

if !strings.EqualFold(actual, test.expected) {
t.Errorf("FindExecutable() actual = %v, expected = %v", actual, test.expected)
}
assert.NoError(t, err)
assert.Equal(t, strings.ToLower(test.expected), strings.ToLower(actual))
})
}
}

0 comments on commit 6d7a64e

Please sign in to comment.