mirror of
https://github.com/taigrr/wtf
synced 2026-03-29 16:55:23 -07:00
Fix the naming and specs for some utility functions
This commit is contained in:
@@ -2,11 +2,17 @@ package utils
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
. "github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func Test_DoesNotInclude(t *testing.T) {
|
||||
Equal(t, true, DoesNotInclude([]string{"cat", "dog", "rat"}, "bat"))
|
||||
Equal(t, false, DoesNotInclude([]string{"cat", "dog", "rat"}, "dog"))
|
||||
}
|
||||
|
||||
func Test_ExecuteCommand(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -44,7 +50,26 @@ func Test_FindMatch(t *testing.T) {
|
||||
Equal(t, expected, result)
|
||||
}
|
||||
|
||||
func Test_ExcludeWhenTrue(t *testing.T) {
|
||||
Equal(t, true, Exclude([]string{"cat", "dog", "rat"}, "bat"))
|
||||
Equal(t, false, Exclude([]string{"cat", "dog", "rat"}, "dog"))
|
||||
func Test_ReadFileBytes(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
file string
|
||||
expected []byte
|
||||
}{
|
||||
{
|
||||
name: "with non-existant file",
|
||||
file: "/tmp/junk-daa6bf613f4c.md",
|
||||
expected: []byte{},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
actual, _ := ReadFileBytes(tt.file)
|
||||
|
||||
if reflect.DeepEqual(tt.expected, actual) == false {
|
||||
t.Errorf("\nexpected: %q\n got: %q", tt.expected, actual)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user