weldrcheck: Add tests for blueprint errors
Add tests for things like posting invalid or empty blueprints, non-existent blueprints, and commits.
This commit is contained in:
parent
6acc205a68
commit
36c19d756a
1 changed files with 353 additions and 0 deletions
|
|
@ -86,6 +86,47 @@ func (c *checkBlueprintsV0) CheckPostTOML() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// POST an invalid TOML blueprint
|
||||||
|
func (c *checkBlueprintsV0) CheckPostInvalidTOML() bool {
|
||||||
|
name := "POST of an invalid TOML blueprint"
|
||||||
|
|
||||||
|
bp := `
|
||||||
|
name="test-invalid-toml-blueprint-v0"
|
||||||
|
version="0.0.1"
|
||||||
|
[package
|
||||||
|
name="bash"
|
||||||
|
version="*"
|
||||||
|
`
|
||||||
|
resp, err := client.PostTOMLBlueprintV0(c.socket, bp)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("FAIL: %s failed with a client error: %s", name, err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if resp.Status {
|
||||||
|
log.Printf("FAIL: %s did not return an error", name)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
log.Printf("OK: %s was successful", name)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST an empty TOML blueprint
|
||||||
|
func (c *checkBlueprintsV0) CheckPostEmptyTOML() bool {
|
||||||
|
name := "POST of an empty TOML blueprint"
|
||||||
|
|
||||||
|
resp, err := client.PostTOMLBlueprintV0(c.socket, "")
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("FAIL: %s failed with a client error: %s", name, err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if resp.Status {
|
||||||
|
log.Printf("FAIL: %s did not return an error", name)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
log.Printf("OK: %s was successful", name)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// POST a new JSON blueprint
|
// POST a new JSON blueprint
|
||||||
func (c *checkBlueprintsV0) CheckPostJSON() bool {
|
func (c *checkBlueprintsV0) CheckPostJSON() bool {
|
||||||
name := "POST of a JSON blueprint"
|
name := "POST of a JSON blueprint"
|
||||||
|
|
@ -112,6 +153,46 @@ func (c *checkBlueprintsV0) CheckPostJSON() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// POST an invalid JSON blueprint
|
||||||
|
func (c *checkBlueprintsV0) CheckPostInvalidJSON() bool {
|
||||||
|
name := "POST of an invalid JSON blueprint"
|
||||||
|
|
||||||
|
bp := `{
|
||||||
|
"name": "test-invalid-json-blueprint-v0",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"modules": [{"name: "util-linux", "version": "*"}],
|
||||||
|
}`
|
||||||
|
|
||||||
|
resp, err := client.PostJSONBlueprintV0(c.socket, bp)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("FAIL: %s failed with a client error: %s", name, err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if resp.Status {
|
||||||
|
log.Printf("FAIL: %s did not return an error", name)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
log.Printf("OK: %s was successful", name)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST an empty JSON blueprint
|
||||||
|
func (c *checkBlueprintsV0) CheckPostEmptyJSON() bool {
|
||||||
|
name := "POST of an empty JSON blueprint"
|
||||||
|
|
||||||
|
resp, err := client.PostJSONBlueprintV0(c.socket, "")
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("FAIL: %s failed with a client error: %s", name, err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if resp.Status {
|
||||||
|
log.Printf("FAIL: %s did not return an error", name)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
log.Printf("OK: %s was successful", name)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// POST a blueprint to the workspace as TOML
|
// POST a blueprint to the workspace as TOML
|
||||||
func (c *checkBlueprintsV0) CheckPostTOMLWS() bool {
|
func (c *checkBlueprintsV0) CheckPostTOMLWS() bool {
|
||||||
name := "POST TOML blueprint to workspace"
|
name := "POST TOML blueprint to workspace"
|
||||||
|
|
@ -145,6 +226,47 @@ func (c *checkBlueprintsV0) CheckPostTOMLWS() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// POST an invalid TOML blueprint to the workspace
|
||||||
|
func (c *checkBlueprintsV0) CheckPostInvalidTOMLWS() bool {
|
||||||
|
name := "POST of an invalid TOML blueprint to workspace"
|
||||||
|
|
||||||
|
bp := `
|
||||||
|
name="test-invalid-toml-blueprint-ws-v0"
|
||||||
|
version="0.0.1"
|
||||||
|
[package
|
||||||
|
name="bash"
|
||||||
|
version="*"
|
||||||
|
`
|
||||||
|
resp, err := client.PostTOMLWorkspaceV0(c.socket, bp)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("FAIL: %s failed with a client error: %s", name, err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if resp.Status {
|
||||||
|
log.Printf("FAIL: %s did not return an error", name)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
log.Printf("OK: %s was successful", name)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST an empty TOML blueprint to the workspace
|
||||||
|
func (c *checkBlueprintsV0) CheckPostEmptyTOMLWS() bool {
|
||||||
|
name := "POST of an empty TOML blueprint to workspace"
|
||||||
|
|
||||||
|
resp, err := client.PostTOMLWorkspaceV0(c.socket, "")
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("FAIL: %s failed with a client error: %s", name, err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if resp.Status {
|
||||||
|
log.Printf("FAIL: %s did not return an error", name)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
log.Printf("OK: %s was successful", name)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// POST a blueprint to the workspace as JSON
|
// POST a blueprint to the workspace as JSON
|
||||||
func (c *checkBlueprintsV0) CheckPostJSONWS() bool {
|
func (c *checkBlueprintsV0) CheckPostJSONWS() bool {
|
||||||
name := "POST JSON blueprint to workspace"
|
name := "POST JSON blueprint to workspace"
|
||||||
|
|
@ -171,6 +293,46 @@ func (c *checkBlueprintsV0) CheckPostJSONWS() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// POST an invalid JSON blueprint to the workspace
|
||||||
|
func (c *checkBlueprintsV0) CheckPostInvalidJSONWS() bool {
|
||||||
|
name := "POST of an invalid JSON blueprint to workspace"
|
||||||
|
|
||||||
|
bp := `{
|
||||||
|
"name": "test-invalid-json-blueprint-ws-v0",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"modules": [{"name: "util-linux", "version": "*"}],
|
||||||
|
}`
|
||||||
|
|
||||||
|
resp, err := client.PostJSONBlueprintV0(c.socket, bp)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("FAIL: %s failed with a client error: %s", name, err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if resp.Status {
|
||||||
|
log.Printf("FAIL: %s did not return an error", name)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
log.Printf("OK: %s was successful", name)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST an empty JSON blueprint to the workspace
|
||||||
|
func (c *checkBlueprintsV0) CheckPostEmptyJSONWS() bool {
|
||||||
|
name := "POST of an empty JSON blueprint to workspace"
|
||||||
|
|
||||||
|
resp, err := client.PostJSONBlueprintV0(c.socket, "")
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("FAIL: %s failed with a client error: %s", name, err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if resp.Status {
|
||||||
|
log.Printf("FAIL: %s did not return an error", name)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
log.Printf("OK: %s was successful", name)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// delete a blueprint
|
// delete a blueprint
|
||||||
func (c *checkBlueprintsV0) CheckDelete() bool {
|
func (c *checkBlueprintsV0) CheckDelete() bool {
|
||||||
name := "DELETE blueprint"
|
name := "DELETE blueprint"
|
||||||
|
|
@ -210,6 +372,24 @@ func (c *checkBlueprintsV0) CheckDelete() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// delete a non-existent blueprint
|
||||||
|
func (c *checkBlueprintsV0) CheckDeleteNonBlueprint() bool {
|
||||||
|
name := "DELETE a non-existent blueprint"
|
||||||
|
|
||||||
|
resp, err := client.DeleteBlueprintV0(c.socket, "test-delete-non-blueprint-v0")
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("FAIL: %s failed with a client error: %s", name, err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if resp.Status {
|
||||||
|
log.Printf("FAIL: %s did not return an error", name)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("OK: %s was successful", name)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// delete a new blueprint from the workspace
|
// delete a new blueprint from the workspace
|
||||||
func (c *checkBlueprintsV0) CheckDeleteNewWS() bool {
|
func (c *checkBlueprintsV0) CheckDeleteNewWS() bool {
|
||||||
name := "DELETE new blueprint from workspace"
|
name := "DELETE new blueprint from workspace"
|
||||||
|
|
@ -496,6 +676,24 @@ func (c *checkBlueprintsV0) CheckGetTOML() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get non-existent blueprint contents as TOML
|
||||||
|
func (c *checkBlueprintsV0) CheckGetNonTOML() bool {
|
||||||
|
name := "Get non-existent TOML Blueprint"
|
||||||
|
|
||||||
|
_, api, err := client.GetBlueprintInfoTOMLV0(c.socket, "test-get-non-blueprint-1-v0")
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("FAIL: %s failed: %s", name, err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if api == nil || api.Status {
|
||||||
|
log.Printf("FAIL: %s did not return an error", name)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("OK: %s was successful", name)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// get blueprint contents as JSON
|
// get blueprint contents as JSON
|
||||||
func (c *checkBlueprintsV0) CheckGetJSON() bool {
|
func (c *checkBlueprintsV0) CheckGetJSON() bool {
|
||||||
name := "Get JSON Blueprint"
|
name := "Get JSON Blueprint"
|
||||||
|
|
@ -559,6 +757,24 @@ func (c *checkBlueprintsV0) CheckGetJSON() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get non-existent blueprint contents as JSON
|
||||||
|
func (c *checkBlueprintsV0) CheckGetNonJSON() bool {
|
||||||
|
name := "Get non-existent JSON Blueprint"
|
||||||
|
|
||||||
|
_, api, err := client.GetBlueprintsInfoJSONV0(c.socket, "test-get-non-blueprint-1-v0")
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("FAIL: %s failed: %s", name, err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if api == nil || api.Status {
|
||||||
|
log.Printf("FAIL: %s did not return an error", name)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("OK: %s was successful", name)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// pushing the same blueprint bumps the version number returned by show
|
// pushing the same blueprint bumps the version number returned by show
|
||||||
func (c *checkBlueprintsV0) CheckBumpVersion() bool {
|
func (c *checkBlueprintsV0) CheckBumpVersion() bool {
|
||||||
name := "Bump Blueprint Version number"
|
name := "Bump Blueprint Version number"
|
||||||
|
|
@ -720,6 +936,24 @@ func (c *checkBlueprintsV0) CheckBlueprintChangesV0() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get changes for a non-existent blueprint
|
||||||
|
func (c *checkBlueprintsV0) CheckBlueprintNonChangesV0() bool {
|
||||||
|
name := "List non-existent blueprint changes"
|
||||||
|
|
||||||
|
_, api, err := client.GetBlueprintsChangesV0(c.socket, []string{"test-non-blueprint-changes-v0"})
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("FAIL: %s failed: %s", name, err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if api == nil || api.Status {
|
||||||
|
log.Printf("FAIL: %s failed to return an error", name)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("OK: %s was successful", name)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// Undo blueprint changes
|
// Undo blueprint changes
|
||||||
func (c *checkBlueprintsV0) CheckUndoBlueprintV0() bool {
|
func (c *checkBlueprintsV0) CheckUndoBlueprintV0() bool {
|
||||||
name := "Undo blueprint changes"
|
name := "Undo blueprint changes"
|
||||||
|
|
@ -861,6 +1095,71 @@ func (c *checkBlueprintsV0) CheckUndoBlueprintV0() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Undo non-existent commit blueprint changes
|
||||||
|
func (c *checkBlueprintsV0) CheckUndoBlueprintNonCommitV0() bool {
|
||||||
|
name := "Undo blueprint non-existent commit"
|
||||||
|
|
||||||
|
bps := []string{`{
|
||||||
|
"name": "test-undo-blueprint-non-commit-v0",
|
||||||
|
"description": "CheckUndoBlueprintNonCommitV0",
|
||||||
|
"version": "0.0.5",
|
||||||
|
"packages": [{"name": "bash", "version": "*"}],
|
||||||
|
"modules": [{"name": "util-linux", "version": "*"}],
|
||||||
|
"customizations": {"user": [{"name": "root", "password": "qweqweqwe"}]}
|
||||||
|
}`,
|
||||||
|
`{
|
||||||
|
"name": "test-undo-blueprint-non-commit-v0",
|
||||||
|
"description": "CheckUndoBlueprintNonCommitv0",
|
||||||
|
"version": "0.0.6",
|
||||||
|
"packages": [{"name": "bash", "version": "0.5.*"}],
|
||||||
|
"modules": [{"name": "util-linux", "version": "*"}],
|
||||||
|
"customizations": {"user": [{"name": "root", "password": "qweqweqwe"}]}
|
||||||
|
}`}
|
||||||
|
|
||||||
|
for i := range bps {
|
||||||
|
resp, err := client.PostJSONBlueprintV0(c.socket, bps[i])
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("FAIL: %s failed with a client error: %s", name, err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if !resp.Status {
|
||||||
|
log.Printf("FAIL: %s failed: %s", name, resp)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.UndoBlueprintChangeV0(c.socket, "test-undo-blueprint-non-commit-v0", "FFFF")
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("FAIL: %s failed with a client error: %s", name, err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if resp.Status {
|
||||||
|
log.Printf("FAIL: %s did not return an error", name)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("OK: %s was successful", name)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Undo non-existent blueprint changes
|
||||||
|
func (c *checkBlueprintsV0) CheckUndoNonBlueprintV0() bool {
|
||||||
|
name := "Undo non-existent blueprint changes"
|
||||||
|
|
||||||
|
resp, err := client.UndoBlueprintChangeV0(c.socket, "test-undo-non-blueprint-v0", "FFFF")
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("FAIL: %s failed with a client error: %s", name, err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if resp.Status {
|
||||||
|
log.Printf("FAIL: %s did not return an error", name)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("OK: %s was successful", name)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// Tag a blueprint with a new revision
|
// Tag a blueprint with a new revision
|
||||||
// The blueprint revision tag cannot be reset, it always increments by one, and cannot be deleted.
|
// The blueprint revision tag cannot be reset, it always increments by one, and cannot be deleted.
|
||||||
// So to test tagging we tag two blueprint changes and make sure the second is first +1
|
// So to test tagging we tag two blueprint changes and make sure the second is first +1
|
||||||
|
|
@ -986,6 +1285,24 @@ func (c *checkBlueprintsV0) CheckBlueprintTagV0() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tag a non-existent blueprint
|
||||||
|
func (c *checkBlueprintsV0) CheckNonBlueprintTagV0() bool {
|
||||||
|
name := "Tag a non-existent blueprint"
|
||||||
|
|
||||||
|
tagResp, err := client.TagBlueprintV0(c.socket, "test-tag-non-blueprint-v0")
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("FAIL: %s failed with a client error: %s", name, err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if tagResp.Status {
|
||||||
|
log.Printf("FAIL: %s failed to return an error", name)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("OK: %s was successful", name)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// depsolve a blueprint with packages and modules
|
// depsolve a blueprint with packages and modules
|
||||||
func (c *checkBlueprintsV0) CheckBlueprintDepsolveV0() bool {
|
func (c *checkBlueprintsV0) CheckBlueprintDepsolveV0() bool {
|
||||||
name := "Depsolve a blueprint"
|
name := "Depsolve a blueprint"
|
||||||
|
|
@ -1037,6 +1354,24 @@ func (c *checkBlueprintsV0) CheckBlueprintDepsolveV0() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// depsolve a non-existent blueprint
|
||||||
|
func (c *checkBlueprintsV0) CheckNonBlueprintDepsolveV0() bool {
|
||||||
|
name := "Depsolve a non-existent blueprint"
|
||||||
|
|
||||||
|
_, api, err := client.DepsolveBlueprintV0(c.socket, "test-deps-non-blueprint-v0")
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("FAIL: %s failed: %s", name, err.Error())
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if api == nil || api.Status {
|
||||||
|
log.Printf("FAIL: %s failed to return an error", name)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("OK: %s was successful", name)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// freeze a blueprint
|
// freeze a blueprint
|
||||||
func (c *checkBlueprintsV0) CheckBlueprintFreezeV0() bool {
|
func (c *checkBlueprintsV0) CheckBlueprintFreezeV0() bool {
|
||||||
name := "Freeze a blueprint"
|
name := "Freeze a blueprint"
|
||||||
|
|
@ -1102,6 +1437,24 @@ func (c *checkBlueprintsV0) CheckBlueprintFreezeV0() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// freeze a non-existent blueprint
|
||||||
|
func (c *checkBlueprintsV0) CheckNonBlueprintFreezeV0() bool {
|
||||||
|
name := "Freeze a non-existent blueprint"
|
||||||
|
|
||||||
|
_, api, err := client.FreezeBlueprintV0(c.socket, "test-freeze-non-blueprint-v0")
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("FAIL: %s failed: %s", name, err.Error())
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if api == nil || api.Status {
|
||||||
|
log.Printf("FAIL: %s failed to return an error", name)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("OK: %s was successful", name)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// diff of blueprint changes
|
// diff of blueprint changes
|
||||||
func (c *checkBlueprintsV0) CheckBlueprintDiffV0() bool {
|
func (c *checkBlueprintsV0) CheckBlueprintDiffV0() bool {
|
||||||
name := "Diff of blueprint changes"
|
name := "Diff of blueprint changes"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue