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

create_remote_file fails with action :create_if_missing #118

Closed
1 of 3 tasks
danryu opened this issue Mar 25, 2013 · 7 comments
Closed
1 of 3 tasks

create_remote_file fails with action :create_if_missing #118

danryu opened this issue Mar 25, 2013 · 7 comments

Comments

@danryu
Copy link

danryu commented Mar 25, 2013

I want a tarball to download only if it does not already exist. That's why I use :create_if_missing in my recipe.

IMO the test "create_remote_file" should succeed for remote_file resources declared with action:create_if_missing as well as action:create.

EDIT: This seems to apply to create_cookbook_file as well.

The following output shows what I get when I run chefspec with this resource defined:

remote_file "/tmp/gi.tar.gz" do
source "#{node[:application_tier][:package_url]}"
owner "root"
group "root"
mode "0755"
action :create_if_missing
end

Chefspec Output:
2) application_tier::install should download tarball
Failure/Error: chef_run.should create_remote_file '/tmp/bi.tar.gz'
ArgumentError:
Failure message is nil. Does your matcher define the appropriate failure_message_for_* method to return a string?
# ./chef__repo/cookbooks/application_tier/spec/install_spec.rb:8:in `block (2 levels) in <top (required)>'


I've converted this to a list:

  • create_remote_file_if_missing (thanks @jimhopp-lookout)
  • delete_remote_file
  • touch_remote_file
@phoolish
Copy link

This applies to the file resource as well.

@sethvargo
Copy link
Contributor

/cc @jtimberman

@pschultz
Copy link

pschultz commented Jun 5, 2013

And it applies to templates too.

@jimhopp-lookout
Copy link
Contributor

I ran into this when I upgraded from chefspec 0.9.0 to 1.3.1. The problem is indeed that, now, the create_remote_file matcher only matches on action :create.

I'll take a crack at adding support for an action parm to this matcher and submit a pull request.

@jimhopp-lookout
Copy link
Contributor

I realized this should probably be addressed with new matchers:
create_remote_file_if_missing
delete_remote_file
touch_remote_file

@phoolish
Copy link

Still can't get this to work for file resource.

@sethvargo
Copy link
Contributor

Released in 2.0.0

@lock lock bot locked as resolved and limited conversation to collaborators Aug 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants