mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-06 07:57:07 +00:00
* Added jsonpointer package that supports parsing of paths and JSON pointers that can yield either a JSON pointer string or JMESPath string. * Replaced the use of `strings.Split` and `strings.Join` in places where paths are converted to JMESPaths. Signed-off-by: Tobias Dahlberg <tobias.dahlberg@sinch.com> Signed-off-by: Tobias Dahlberg <tobias.dahlberg@sinch.com> Co-authored-by: shuting <shuting@nirmata.com> Co-authored-by: Prateek Pandey <prateek.pandey@nirmata.com> Co-authored-by: Vyankatesh Kudtarkar <vyankateshkd@gmail.com>
29 lines
547 B
Go
29 lines
547 B
Go
package utils
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestGetAnchorsFromMap_ThereAreNoAnchors(t *testing.T) {
|
|
rawMap := []byte(`{
|
|
"name":"nirmata-*",
|
|
"notAnchor1":123,
|
|
"namespace":"kube-?olicy",
|
|
"notAnchor2":"sample-text",
|
|
"object":{
|
|
"key1":"value1",
|
|
"(key2)":"value2"
|
|
}
|
|
}`)
|
|
|
|
var unmarshalled map[string]interface{}
|
|
err := json.Unmarshal(rawMap, &unmarshalled)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
actualMap := GetAnchorsFromMap(unmarshalled)
|
|
assert.Equal(t, len(actualMap), 0)
|
|
}
|