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

Add Itamae::Runner recipe_files argument data type validation #356

Merged
merged 1 commit into from
Jul 10, 2022
Merged
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
4 changes: 4 additions & 0 deletions lib/itamae/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ module Itamae
class Runner
class << self
def run(recipe_files, backend_type, options)
unless recipe_files.is_a? Array
raise ArgumentError, 'recipe_files must be an Array'
end

Itamae.logger.info "Starting Itamae... #{options[:dry_run] ? '(dry-run)' : ''}"

backend = Backend.create(backend_type, options)
Expand Down
8 changes: 8 additions & 0 deletions spec/unit/lib/itamae/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ module Itamae
end
described_class.run(recipes, :local, {})
end

it "raises error for invalid recipes argument type" do
[nil, "recipe.rb"].each do |recipe|
expect do
described_class.run(recipe, :local, {})
end.to raise_error(ArgumentError, 'recipe_files must be an Array')
end
end
end

describe "#initialize" do
Expand Down