1
0
Fork 0
mirror of https://github.com/Luzifer/go_helpers.git synced 2024-12-25 13:31:21 +00:00
go_helpers/which/which_test.go
Knut Ahlers 63159db627
Remove gomega from tests and update dependencies
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2023-10-12 13:39:52 +02:00

30 lines
691 B
Go

package which_test
import (
"testing"
. "github.com/Luzifer/go_helpers/v2/which"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestFindInDirectory(t *testing.T) {
found, err := FindInDirectory("bash", "/bin")
require.NoError(t, err)
assert.True(t, found)
}
func TestFindInPath(t *testing.T) {
// Searching bash on the system
result, err := FindInPath("bash")
assert.NoError(t, err)
assert.Greater(t, len(result), 0)
// Searching a non existent file
_, err = FindInPath("dfqoiwurgtqi3uegrds")
assert.ErrorIs(t, err, ErrBinaryNotFound)
// Searching an empty file
_, err = FindInPath("")
assert.ErrorIs(t, err, ErrNoSearchSpecified)
}