mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-05-02 13:44:33 +00:00
annotations: Add unit test for checkPathIsInGlobs
There are a few interesting corner cases to consider for this function. Fixes: #901 Suggested-by: James O.D. Hunt <james.o.hunt@intel.com> Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
This commit is contained in:
parent
6f52179ce4
commit
b2b3bc7ad8
@ -923,6 +923,37 @@ func TestRegexpContains(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckPathIsInGlobs(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
type testData struct {
|
||||
globs []string
|
||||
toMatch string
|
||||
expected bool
|
||||
}
|
||||
|
||||
data := []testData{
|
||||
{[]string{}, "", false},
|
||||
{[]string{}, "nonempty", false},
|
||||
{[]string{"simple"}, "simple", false},
|
||||
{[]string{"simple"}, "some_simple_text", false},
|
||||
{[]string{"/bin/ls"}, "/bin/ls", true},
|
||||
{[]string{"/bin/ls", "/bin/false"}, "/bin/ls", true},
|
||||
{[]string{"/bin/ls", "/bin/false"}, "/bin/false", true},
|
||||
{[]string{"/bin/ls", "/bin/false"}, "/bin/bar", false},
|
||||
{[]string{"/bin/*ls*"}, "/bin/ls", true},
|
||||
{[]string{"/bin/*ls*"}, "/bin/false", true},
|
||||
{[]string{"bin/ls"}, "/bin/ls", false},
|
||||
{[]string{"./bin/ls"}, "/bin/ls", false},
|
||||
{[]string{"*/bin/ls"}, "/bin/ls", false},
|
||||
}
|
||||
|
||||
for _, d := range data {
|
||||
matched := checkPathIsInGlobs(d.globs, d.toMatch)
|
||||
assert.Equal(d.expected, matched, "%+v", d)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsCRIOContainerManager(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user