-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test cases for validation process
- Loading branch information
Showing
9 changed files
with
98 additions
and
1 deletion.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
tests/scripts/app-workflows/fixtures/validate-good-response.json
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 @@ | ||
{ "status": "OK", "version": "v2.999.0", "sha": "1234567890ABCDEF" } |
1 change: 1 addition & 0 deletions
1
tests/scripts/app-workflows/fixtures/validate-invalid-json-response.json
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 @@ | ||
{ "status": "OK", "version": "undefined", "sha": "undefined" |
1 change: 1 addition & 0 deletions
1
tests/scripts/app-workflows/fixtures/validate-non-json-response.json
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 @@ | ||
"Invalid Response Format" |
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 @@ | ||
{ "status": "OK", "version": "v2.999.0", "sha": "BAD_SHA" } |
1 change: 1 addition & 0 deletions
1
tests/scripts/app-workflows/fixtures/validate-status-error.json
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 @@ | ||
{ "status": "BAD_STATUS", "version": "v2.999.0", "sha": "1234567890ABCDEF" } |
1 change: 1 addition & 0 deletions
1
tests/scripts/app-workflows/fixtures/validate-version-error.json
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 @@ | ||
{ "status": "OK", "version": "v1.0.0-BAD", "sha": "1234567890ABCDEF" } |
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,9 @@ | ||
#!/usr/bin/env bats | ||
|
||
load 'test_helpers' | ||
|
||
@test "Test bogus URL" { | ||
run ./scripts/app-workflows/fetch-deploy-info.sh "http://localhost/bogus-url" | ||
test_value 1 "$status" | ||
test_value "Failed to fetch the verification URL: http://localhost/bogus-url" "${lines[0]}" | ||
} |
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,53 @@ | ||
#!/usr/bin/env bats | ||
|
||
load 'test_helpers' | ||
|
||
@test "Test bad status" { | ||
fixture=$(load_json_fixture "validate-status-error.json") | ||
run ./scripts/app-workflows/validate-deploy.sh $fixture "v2.999.0" "1234567890ABCDEF" | ||
test_value 1 "$status" | ||
test_value "Validation failed: status is not OK" "${lines[0]}" | ||
test_value "Expected: OK, Actual: BAD_STATUS" "${lines[1]}" | ||
} | ||
|
||
@test "Test incorrect version" { | ||
fixture=$(load_json_fixture "validate-version-error.json") | ||
run ./scripts/app-workflows/validate-deploy.sh $fixture "v2.999.0" "1234567890ABCDEF" | ||
test_value 1 "$status" | ||
test_value "Validation failed: version mismatch" "${lines[0]}" | ||
test_value "Expected: v2.999.0, Actual: v1.0.0-BAD" "${lines[1]}" | ||
} | ||
|
||
@test "Test incorrect sha" { | ||
fixture=$(load_json_fixture "validate-sha-error.json") | ||
run ./scripts/app-workflows/validate-deploy.sh $fixture "v2.999.0" "1234567890ABCDEF" | ||
test_value 1 "$status" | ||
test_value "Validation failed: sha mismatch" "${lines[0]}" | ||
test_value "Expected: 1234567890ABCDEF, Actual: BAD_SHA" "${lines[1]}" | ||
} | ||
|
||
@test "Test valid response" { | ||
fixture=$(load_json_fixture "validate-good-response.json") | ||
run ./scripts/app-workflows/validate-deploy.sh $fixture "v2.999.0" "1234567890ABCDEF" | ||
test_value 0 "$status" | ||
} | ||
|
||
@test "Test non-JSON response" { | ||
fixture=$(load_json_fixture "validate-non-json-response.json") | ||
run ./scripts/app-workflows/validate-deploy.sh '$fixture' "v2.999.0" "1234567890ABCDEF" | ||
test_value 1 "$status" | ||
test_value "Error: Invalid JSON string" "${lines[0]}" | ||
} | ||
|
||
@test "Test invalid JSON response" { | ||
fixture=$(load_json_fixture "validate-invalid-json-response.json") | ||
run ./scripts/app-workflows/validate-deploy.sh '$fixture' "v2.999.0" "1234567890ABCDEF" | ||
test_value 1 "$status" | ||
test_value "Error: Invalid JSON string" "${lines[0]}" | ||
} | ||
|
||
@test "Test empty response" { | ||
run ./scripts/app-workflows/validate-deploy.sh "" "v2.999.0" "1234567890ABCDEF" | ||
test_value 1 "$status" | ||
test_value "Error: Invalid JSON string" "${lines[0]}" | ||
} |
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