1
0
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:
Chris Cummer
2019-08-05 11:40:42 -07:00
parent ecd95ba2d2
commit 3e2d6eb5fa
5 changed files with 61 additions and 28 deletions

View File

@@ -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)
}
})
}
}