-
Notifications
You must be signed in to change notification settings - Fork 225
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
BoltSpec expect_upload
assumes source file resides inside the module
#2905
Comments
Not quite sure how I want to solve this. The problem is the Most straight-forward option seems to be registering another object like inventory/executor with Puppet.lookup and using that. We could then mock it out in BoltSpec. That seems a little convoluted though. Last one I haven't figured out how to do is directly mock file calls in BoltSpec or override functions rather than the Executor. |
@MikaelSmith if rspec-puppet had a generalized function mock, this would not need to be handled in BoltSpec. A generalized rspec-puppet function mock would actually be the preferred solution to this problem. |
Yeah. I need to test whether the approaches in rodjek/rspec-puppet#684 work for Bolt plans. |
I decided not to try to solve for mocking out the file lookup. It's easy enough to create a temporary file for these tests. Improvements to rspec-puppet would still be welcome, but I think we can make some small improvements here. |
I poked around with repeating the linked workarounds in Bolt last time I looked at this, and was very unsatisfied with the options and results. The existing rspec-puppet means of bumbling through this problem aren't true mocks, they're just workarounds. I wouldn't be keen to simply repeat that hack in BoltSpec. It would be better to provide a real mock, probably using Puppet's internal function loaders somehow. 🤷 |
Updates BoltSpec `allow/expect_upload` and `allow/expect_script` functions to accept an absolute path. The path referred to must still exist, but that's relatively easy to mock with temporary files. ---- !bug * **Update BoltSpec functions to allow absolute paths** ([puppetlabs#2905](puppetlabs#2905)) BoltSpec's `allow_upload`, `expect_upload`, `allow_script`, and `expect_script` functions now support passing absolute paths that rather than a module reference. The referenced path must refer to a real file or upload and script functions will still error.
Updates BoltSpec `allow/expect_upload` and `allow/expect_script` functions to accept an absolute path. The path referred to must still exist, but that's relatively easy to mock with temporary files. ---- !bug * **Update BoltSpec functions to allow absolute paths** ([puppetlabs#2905](puppetlabs#2905)) BoltSpec's `allow_upload`, `expect_upload`, `allow_script`, and `expect_script` functions now support passing absolute paths that rather than a module reference. The referenced path must refer to a real file or upload and script functions will still error.
(GH-2905) Update BoltSpec functions to allow absolute paths
This issue has not had activity for 60 days and will be marked as stale. |
This issue is stale and has been closed. If you believe this is in error, |
Describe the Bug
Currently, the expect_upload BoltSpec function assumes the uploaded file resides inside the module. This limits its usefulness as the following example shows:
https://github.com/puppetlabs/puppetlabs-peadm/blob/main/spec/plans/util/retrieve_and_upload_spec.rb#L17-L27
The above example implements a work-around for mocking the upload_file call as defined here: https://github.com/puppetlabs/puppetlabs-peadm/blob/main/plans/util/retrieve_and_upload.pp#L32
Expected Behavior
When mocking
upload_file
with an absolute path source argument, the mock should not fail because the file is not present on the filesystem. This is a mock.Steps to Reproduce
upload_file
with an absolute source path such as "/tmp/not-a-real-file"expect_upload
The text was updated successfully, but these errors were encountered: