Skip to content

Commit

Permalink
Add tests and godebug to compare structs
Browse files Browse the repository at this point in the history
  • Loading branch information
aledbf committed Jan 13, 2017
1 parent dbd368a commit 64a5e43
Show file tree
Hide file tree
Showing 10 changed files with 865 additions and 9 deletions.
8 changes: 8 additions & 0 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions controllers/nginx/pkg/template/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 6 additions & 5 deletions controllers/nginx/pkg/template/configmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package template

import (
"reflect"
"testing"

"github.com/kylelemons/godebug/pretty"
Expand Down Expand Up @@ -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{
Expand Down
202 changes: 202 additions & 0 deletions vendor/github.com/kylelemons/godebug/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 64a5e43

Please sign in to comment.