GODT-1650: text/html sending tests

This commit is contained in:
James Houlahan
2022-10-04 16:27:38 +02:00
parent ba9368426c
commit c953b8030a
12 changed files with 535 additions and 165 deletions

View File

@ -1,11 +1,27 @@
package tests
import (
"encoding/json"
"reflect"
"github.com/bradenaw/juniper/xslices"
)
func ToAny(v any) any {
b, err := json.Marshal(v)
if err != nil {
panic(err)
}
var a any
if err := json.Unmarshal(b, &a); err != nil {
panic(err)
}
return a
}
func IsSub(outer, inner any) bool {
if outer == nil && inner != nil {
return IsSub(reflect.Zero(reflect.TypeOf(inner)).Interface(), inner)
@ -30,10 +46,6 @@ func IsSub(outer, inner any) bool {
return false
}
if len(inner) != len(outer) {
return false
}
return isSubSlice(outer, inner)
default:
@ -69,6 +81,10 @@ func isSubMap(outer, inner map[string]any) bool {
}
func isSubSlice(outer, inner []any) bool {
if len(inner) != len(outer) {
return false
}
for _, v := range inner {
if xslices.IndexFunc(outer, func(outer any) bool {
return IsSub(outer, v)