From 99ca35f18598f77bcf260f91044116365d8e3c26 Mon Sep 17 00:00:00 2001 From: baude Date: Thu, 2 Nov 2017 08:09:17 -0500 Subject: util_test.go: Unittests for util.go Add unit tests for func StringInSlice. Signed-off-by: baude --- libpod/util_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 libpod/util_test.go (limited to 'libpod') diff --git a/libpod/util_test.go b/libpod/util_test.go new file mode 100644 index 000000000..b3d336d1f --- /dev/null +++ b/libpod/util_test.go @@ -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{})) +} \ No newline at end of file -- cgit v1.2.3-54-g00ecf