summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2017-11-02 08:09:17 -0500
committerbaude <bbaude@redhat.com>2017-11-03 20:37:27 -0500
commit99ca35f18598f77bcf260f91044116365d8e3c26 (patch)
treec6699563dee37e4cc90a303ca343d2ad919e9ba7
parent46d762176eafb748b2094bd518ecf66d86388779 (diff)
downloadpodman-99ca35f18598f77bcf260f91044116365d8e3c26.tar.gz
podman-99ca35f18598f77bcf260f91044116365d8e3c26.tar.bz2
podman-99ca35f18598f77bcf260f91044116365d8e3c26.zip
util_test.go: Unittests for util.go
Add unit tests for func StringInSlice. Signed-off-by: baude <bbaude@redhat.com>
-rw-r--r--cmd/kpod/create_cli_test.go3
-rw-r--r--libpod/util_test.go19
2 files changed, 21 insertions, 1 deletions
diff --git a/cmd/kpod/create_cli_test.go b/cmd/kpod/create_cli_test.go
index 928a5ce05..af5c5afae 100644
--- a/cmd/kpod/create_cli_test.go
+++ b/cmd/kpod/create_cli_test.go
@@ -1,10 +1,11 @@
package main
import (
- "github.com/stretchr/testify/assert"
"io/ioutil"
"os"
"testing"
+
+ "github.com/stretchr/testify/assert"
)
var (
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