mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-10 09:56:55 +00:00
assertEq and assertNe utils replaced by gotest.tools/assert, deleted these utils. Implemented proper serialization of JSON patches: all simple types in values are converted to sting, all maps of interfaces are converted to maps of strings. I.e. implemented applying of JSON patches directly from values in policies.
26 lines
722 B
Go
26 lines
722 B
Go
package webhooks_test
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func assertEqDataImpl(t *testing.T, expected, actual []byte, formatModifier string) {
|
|
if len(expected) != len(actual) {
|
|
t.Errorf("len(expected) != len(actual): %d != %d\n1:"+formatModifier+"\n2:"+formatModifier, len(expected), len(actual), expected, actual)
|
|
return
|
|
}
|
|
|
|
for idx, val := range actual {
|
|
if val != expected[idx] {
|
|
t.Errorf("Slices not equal at index %d:\n1:"+formatModifier+"\n2:"+formatModifier, idx, expected, actual)
|
|
}
|
|
}
|
|
}
|
|
|
|
func assertEqData(t *testing.T, expected, actual []byte) {
|
|
assertEqDataImpl(t, expected, actual, "%x")
|
|
}
|
|
|
|
func assertEqStringAndData(t *testing.T, str string, data []byte) {
|
|
assertEqDataImpl(t, []byte(str), data, "%s")
|
|
}
|