Add tests and godebug to compare structs
This commit is contained in:
parent
dbd368adf2
commit
64a5e43394
10 changed files with 865 additions and 9 deletions
|
|
@ -37,10 +37,6 @@ const (
|
|||
|
||||
// ReadConfig obtains the configuration defined by the user merged with the defaults.
|
||||
func ReadConfig(conf *api.ConfigMap) config.Configuration {
|
||||
if len(conf.Data) == 0 {
|
||||
return config.NewDefault()
|
||||
}
|
||||
|
||||
errors := make([]int, 0)
|
||||
skipUrls := make([]string, 0)
|
||||
whitelist := make([]string, 0)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ limitations under the License.
|
|||
package template
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/kylelemons/godebug/pretty"
|
||||
|
|
@ -63,17 +62,19 @@ func TestMergeConfigMapToStruct(t *testing.T) {
|
|||
def.Resolver = h
|
||||
|
||||
to := ReadConfig(conf)
|
||||
if !reflect.DeepEqual(def, to) {
|
||||
t.Errorf("expected %v but retuned %v", def, to)
|
||||
if diff := pretty.Compare(to, def); diff != "" {
|
||||
t.Errorf("unexpected diff: (-got +want)\n%s", diff)
|
||||
}
|
||||
|
||||
def = config.NewDefault()
|
||||
def.Resolver = h
|
||||
to = ReadConfig(&api.ConfigMap{})
|
||||
if !reflect.DeepEqual(def, to) {
|
||||
t.Errorf("expected %v but retuned %v", def, to)
|
||||
if diff := pretty.Compare(to, def); diff != "" {
|
||||
t.Errorf("unexpected diff: (-got +want)\n%s", diff)
|
||||
}
|
||||
|
||||
def = config.NewDefault()
|
||||
def.Resolver = h
|
||||
def.WhitelistSourceRange = []string{"1.1.1.1/32"}
|
||||
to = ReadConfig(&api.ConfigMap{
|
||||
Data: map[string]string{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue