-
Notifications
You must be signed in to change notification settings - Fork 38
/
contains_test.go
38 lines (32 loc) · 1.04 KB
/
contains_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package assertion
import (
"github.com/stretchr/testify/assert"
"testing"
)
// The non error cases are covered in match_test
func TestContainsWithNonJSONType(t *testing.T) {
var complexNumber complex128
_, err := contains(complexNumber, "foo", "1")
if err == nil {
t.Errorf("Expecting contains to return an error for non JSON encodable data")
}
}
func TestDoesNotContainWithNonJSONType(t *testing.T) {
var complexNumber complex128
_, err := doesNotContain(complexNumber, "foo", "1")
if err == nil {
t.Errorf("Expecting doesNotContain to return an error for non JSON encodable data")
}
}
func TestContainsWithString(t *testing.T) {
s := "s3:Get*"
match, err := contains(s, "Action", "*")
assert.Nil(t, err, "Expecting no error from contains")
assert.True(t, match.Match, "Expecting match for string")
}
func TestContainsWithSliceOfStrings(t *testing.T) {
s := []string{"s3:Get*"}
match, err := contains(s, "Action", "*")
assert.Nil(t, err, "Expecting no error from contains")
assert.True(t, match.Match, "Expecting match for string")
}