mirror of
https://github.com/containers/podman.git
synced 2025-10-25 18:25:59 +08:00
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:
@ -1,10 +1,11 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
19
libpod/util_test.go
Normal file
19
libpod/util_test.go
Normal 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{}))
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user