github.com/interconnectedcloud/qdr-operator@v0.0.0-20210826174505-576d2b33dac7/test/e2e/validation/entity.go (about) 1 package validation 2 3 import ( 4 "github.com/interconnectedcloud/qdr-operator/test/e2e/framework/qdrmanagement/entities" 5 "github.com/onsi/gomega" 6 "reflect" 7 ) 8 9 // ValidateEntityValues uses reflect to compare values from a given entity's field 10 // with the provided value from fieldValues map. 11 // 12 // This way you do not need to compare the whole entity, but just the fields that 13 // are relevant to match. 14 func ValidateEntityValues(entity entities.Entity, fieldValues map[string]interface{}) { 15 element := reflect.Indirect(reflect.ValueOf(entity)) 16 for field, fieldValue := range fieldValues { 17 currentValue := element.FieldByName(field).Interface() 18 gomega.Expect(currentValue).To(gomega.Equal(fieldValue)) 19 } 20 }