Skip to content

Commit

Permalink
ensure openshift examples stay in sync for base attributes (Azure#2986)
Browse files Browse the repository at this point in the history
  • Loading branch information
pweil- authored and jackfrancis committed May 30, 2018
1 parent ac8812f commit 9645794
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions pkg/openshift/examples_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package openshift

import (
"path"
"reflect"
"testing"

"github.com/davecgh/go-spew/spew"

"github.com/Azure/acs-engine/pkg/api"
"github.com/Azure/acs-engine/pkg/i18n"
)

func TestExamplesInSync(t *testing.T) {
baseExampleDir := "../../examples"
baseExample := "openshift.json"

tests := []string{}

locale, err := i18n.LoadTranslations()
if err != nil {
t.Fatalf("error loading translations %v", err)
}

apiloader := &api.Apiloader{
Translator: &i18n.Translator{
Locale: locale,
},
}

baseExampleCS, _, err := apiloader.LoadContainerServiceFromFile(
path.Join(baseExampleDir, baseExample),
false, //don't validate
false, // not update
nil,
)
if err != nil {
t.Fatalf("error parsing the api model: %s", err.Error())
}

for _, test := range tests {
testCS, _, err := apiloader.LoadContainerServiceFromFile(
path.Join(baseExampleDir, test),
false,
false,
nil,
)
if err != nil {
t.Errorf("failed parsing %s: %#v", test, err)
continue
}

// todo normalize where necessary (seems easier than reflect right now)

if !reflect.DeepEqual(baseExampleCS.Properties, testCS.Properties) {
t.Errorf(spew.Sprintf("Testing %s\nExpected:\n%+v\nGot:\n%+v", test, baseExampleCS.Properties, testCS.Properties))
}
}

}

0 comments on commit 9645794

Please sign in to comment.