Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if a workflow payload is valid during sync #59

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,18 @@ def create_workflow_from_payload(name, payload, fail_on_invalid_workflow:)
[nil, err.message]
end

return if payload_error

description = floe_workflow&.comment

configuration_script_payloads.find_or_initialize_by(:name => name).tap do |wf|
wf.update!(
:name => name,
:description => description,
:manager_id => manager_id,
:type => self.class.module_parent::Workflow.name,
:payload => payload,
:payload_type => "json"
:name => name,
:description => description,
:manager_id => manager_id,
:type => self.class.module_parent::Workflow.name,
:payload => payload,
:payload_type => "json",
:payload_valid => !!floe_workflow,
:payload_error => payload_error
)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,18 +206,30 @@ def files_in_repository(git_repo_dir)
context "with workflows with invalid json" do
let(:repo_dir_structure) { %w[invalid_json.asl] }

it "skips the invalid workflow file" do
it "sets the payload_valid and payload_error attributes" do
record = build_record
expect(record.configuration_script_payloads).to be_empty
expect(record.configuration_script_payloads.first).to have_attributes(
:name => "invalid_json.asl",
:payload => "{\"Invalid Json\"\n",
:payload_type => "json",
:payload_valid => false,
:payload_error => "unexpected token at '{\"Invalid Json\"\n'"
)
end
end

context "with workflows with missing states" do
let(:repo_dir_structure) { %w[missing_states.asl] }

it "skips the invalid workflow file" do
it "sets the payload_valid and payload_error attributes" do
record = build_record
expect(record.configuration_script_payloads).to be_empty
expect(record.configuration_script_payloads.first).to have_attributes(
:name => "missing_states.asl",
:payload => "{\"Comment\": \"Missing States\"}\n",
:payload_type => "json",
:payload_valid => false,
:payload_error => "Missing field \"States\""
)
end
end

Expand Down
Loading