-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
keep deep copy logic for container config accessors
Signed-off-by: Vaughn Dice <[email protected]>
- Loading branch information
Showing
3 changed files
with
78 additions
and
8 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,44 @@ | ||
func TestClaimSchema(t *testing.T) { | ||
claim, err := New("my_claim") | ||
assert.NoError(t, err) | ||
|
||
claim.Bundle = &exampleBundle | ||
claim.Result = Result{ | ||
Action: ActionInstall, | ||
Message: "result message", | ||
Status: StatusUnderway, | ||
} | ||
|
||
// override dynamic fields for testing | ||
claim.Revision = staticRevision | ||
claim.Created = staticDate | ||
claim.Modified = staticDate | ||
|
||
// add non-required fields | ||
claim.Parameters = map[string]interface{}{ | ||
"myparam": "myparamvalue", | ||
} | ||
claim.Outputs = map[string]interface{}{ | ||
"myoutput": "myoutputvalue", | ||
} | ||
claim.Custom = []string{ | ||
"anything goes", | ||
} | ||
|
||
claimLoader := gojsonschema.NewGoLoader(claim) | ||
|
||
// Load the claim schema | ||
// TODO: gojsonschema.NewReferenceLoader doesn't support https/tls... PR adding functionality or at least a GHLoader? | ||
pwd, _ := os.Getwd() | ||
sl := gojsonschema.NewSchemaLoader() | ||
claimSchema := gojsonschema.NewReferenceLoader(filepath.Join("file://", pwd, "testdata/claim.schema.json")) | ||
bundleSchema := gojsonschema.NewReferenceLoader(filepath.Join("file://", pwd, "testdata/bundle.schema.json")) | ||
sl.AddSchemas(claimSchema, bundleSchema) | ||
|
||
schema, err := sl.Compile(claimSchema) | ||
assert.NoError(t, err) | ||
|
||
// Validate the claim against the schema | ||
_, err = schema.Validate(claimLoader) | ||
assert.NoError(t, err) | ||
} |
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
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