forked from Azure/acs-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ensure openshift examples stay in sync for base attributes (Azure#2986)
- Loading branch information
1 parent
ac8812f
commit 9645794
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
} | ||
} | ||
|
||
} |