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

Fix an undefined variable error in Validator::Type #89

Merged
merged 1 commit into from
Jun 12, 2020

Conversation

yuta1024
Copy link
Contributor

Description

validate method of Validator::Type has an undefined variable error.
I didn't touch the test code. Because current tests are already passed before fixing and after fixing too.
I wrote the following verification code and ran. After fixing, ChefAPI::Error::InvalidResource is raised correctly.

require 'chef-api'

group = ChefAPI::Resource::Group.new({groupname: 'test', actors: {}})
p group.validate!

Before fixing:

% bundle exec ruby test.rb
Traceback (most recent call last):
	5: from test.rb:4:in `<main>'
	4: from /Users/yuta1024/Workspace/ruby-tmp/vendor/bundle/ruby/2.6.0/gems/chef-api-0.10.5/lib/chef-api/resources/base.rb:777:in `validate!'
	3: from /Users/yuta1024/Workspace/ruby-tmp/vendor/bundle/ruby/2.6.0/gems/chef-api-0.10.5/lib/chef-api/resources/base.rb:795:in `valid?'
	2: from /Users/yuta1024/Workspace/ruby-tmp/vendor/bundle/ruby/2.6.0/gems/chef-api-0.10.5/lib/chef-api/resources/base.rb:795:in `each'
	1: from /Users/yuta1024/Workspace/ruby-tmp/vendor/bundle/ruby/2.6.0/gems/chef-api-0.10.5/lib/chef-api/resources/base.rb:796:in `block in valid?'
/Users/yuta1024/Workspace/ruby-tmp/vendor/bundle/ruby/2.6.0/gems/chef-api-0.10.5/lib/chef-api/validators/type.rb:18:in `validate': undefined local variable or method `type' for #<Validator::Type :actors> (NameError)
Did you mean?  types
               @types

After fixing:

% bundle exec ruby test.rb
Traceback (most recent call last):
	1: from test.rb:3:in `<main>'
/Users/yuta1024/Workspace/ruby-tmp/vendor/bundle/ruby/2.6.0/gems/chef-api-0.10.5/lib/chef-api/resources/base.rb:779:in `validate!': There were errors saving your resource: `actors' must be a kind of [Array] (ChefAPI::Error::InvalidResource)

Related Issue

None

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (non-breaking change that does not add functionality or fix an issue)

Checklist:

  • I have read the CONTRIBUTING document.
  • I have run the pre-merge tests locally and they pass.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • All commits have been signed-off for the Developer Certificate of Origin.

Signed-off-by: Yuta Harima <yuu725@gmail.com>
@yuta1024 yuta1024 requested review from a team as code owners June 12, 2020 16:47
@yuta1024
Copy link
Contributor Author

Local test is passing, but CI tests are failed. Those causes are older ruby version and lint existing code (this is not related my change).
What should I do?

@tas50 tas50 merged commit 255a264 into chef-boneyard:master Jun 12, 2020
@tas50
Copy link
Contributor

tas50 commented Jun 12, 2020

Thanks @yuta1024. I'll cleanup the CI too

@yuta1024 yuta1024 deleted the fix/undef branch June 12, 2020 17:10
@yuta1024
Copy link
Contributor Author

@tas50 Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants