Skip to content

Commit

Permalink
Don't use temp file if only using a single template dir and no additi…
Browse files Browse the repository at this point in the history
…onal input
  • Loading branch information
timothysmith0609 committed Feb 20, 2019
1 parent c2cd0db commit c1700b3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
2 changes: 2 additions & 0 deletions lib/kubernetes-deploy/options_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class << self
def with_consolidated_template_dir(template_dirs)
if template_dirs.empty? && ARGV.empty? && $stdin.tty?
yield default_template_dir
elsif template_dirs.length == 1 && ARGV.empty? && $stdin.tty?
yield template_dirs.first
else
Dir.mktmpdir("kubernetes-deploy") do |dir|
populate_temp_dir(temp_dir: dir, template_dirs: template_dirs)
Expand Down
10 changes: 2 additions & 8 deletions test/unit/kubernetes-deploy/options_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,9 @@ def test_template_dir_with_stdin
$stdin = old_stdin
end

def test_template_dir_only
def test_single_template_dir_only
KubernetesDeploy::OptionsHelper.with_consolidated_template_dir([fixture_path('hello-cloud')]) do |template_dir|
fixture_path_entries = Dir.entries(fixture_path('hello-cloud'))
template_dir_entries = Dir.entries(template_dir)
assert_equal(template_dir_entries.length, fixture_path_entries.length)
fixture_path_entries.each do |fixture|
next if fixture =~ /^\.{1,2}$/
assert template_dir_entries.index { |s| s.include?(fixture) }
end
assert_equal(fixture_path('hello-cloud'), template_dir)
end
end

Expand Down

0 comments on commit c1700b3

Please sign in to comment.