util_test.go: Unittests for util.go

Add unit tests for func StringInSlice.

Signed-off-by: baude <bbaude@redhat.com>
This commit is contained in:
baude
2017-11-02 08:09:17 -05:00
parent 46d762176e
commit 99ca35f185
2 changed files with 21 additions and 1 deletions

View File

@ -1,10 +1,11 @@
package main
import (
"github.com/stretchr/testify/assert"
"io/ioutil"
"os"
"testing"
"github.com/stretchr/testify/assert"
)
var (

19
libpod/util_test.go Normal file
View File

@ -0,0 +1,19 @@
package libpod
import (
"testing"
"github.com/stretchr/testify/assert"
)
var (
sliceData = []string{"one", "two", "three", "four"}
)
func TestStringInSlice(t *testing.T) {
// string is in the slice
assert.True(t, StringInSlice("one", sliceData))
// string is not in the slice
assert.False(t, StringInSlice("five", sliceData))
// string is not in empty slice
assert.False(t, StringInSlice("one", []string{}))
}