Skip to content

Commit

Permalink
Merge pull request #46 from wcooley/wcooley/forge_fixtures-squashed
Browse files Browse the repository at this point in the history
Add support for "forge_modules" in fixtures.
  • Loading branch information
hunner committed Apr 3, 2014
2 parents 85cd67e + 41f00d5 commit aea0102
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,16 @@ Specify that the git tag `2.4.2` of `stdlib' should be checked out:
symlinks:
my_module: "#{source_dir}"

Install modules from Puppet Forge:

fixtures:
forge_modules:
firewall: "puppetlabs/firewall"
stdlib:
repo: "puppetlabs/stdlib"
ref: "2.6.0"


Testing Parser Functions
========================

Expand Down
25 changes: 25 additions & 0 deletions lib/puppetlabs_spec_helper/rake_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,22 @@ def fixtures(category)
File::exists?(target) || FileUtils::ln_sf(source, target)
end

fixtures("forge_modules").each do |remote, opts|
if opts.instance_of?(String)
target = opts
ref = ""
elsif opts.instance_of?(Hash)
target = opts["target"]
ref = "--version #{opts['ref']}"
end
next if File::exists?(target)
unless system("puppet module install " + ref + \
" --ignore-dependencies" \
" --target-dir spec/fixtures/modules #{remote}")
fail "Failed to install module #{remote} to #{target}"
end
end

FileUtils::mkdir_p("spec/fixtures/manifests")
FileUtils::touch("spec/fixtures/manifests/site.pp")
end
Expand All @@ -92,6 +108,15 @@ def fixtures(category)
FileUtils::rm_rf(target)
end

fixtures("forge_modules").each do |remote, opts|
if opts.instance_of?(String)
target = opts
elsif opts.instance_of?(Hash)
target = opts["target"]
end
FileUtils::rm_rf(target)
end

fixtures("symlinks").each do |source, target|
FileUtils::rm_f(target)
end
Expand Down

0 comments on commit aea0102

Please sign in to comment.