mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-15 17:51:20 +00:00
28 lines
534 B
Go
28 lines
534 B
Go
package utils
|
|
|
|
import (
|
|
"encoding/json"
|
|
"gotest.tools/assert"
|
|
"testing"
|
|
)
|
|
|
|
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.Assert(t, len(actualMap) == 0)
|
|
}
|