factor out wrap_environment

This commit is contained in:
David Dollar
2012-04-20 17:40:53 -04:00
parent e06f4b2f9e
commit ce3003b026
3 changed files with 4 additions and 16 deletions

View File

@@ -5,7 +5,7 @@ engine.procfile.entries.each do |process|
1.upto(self.concurrency[process.name]) do |num|
port = engine.port_for(process, num, self.port)
name = if (conc > 1); "#{process.name}-#{num}" else process.name; end
environment = (engine.environment.map{ |var,env| "#{var.upcase}=#{wrap_environment env}" } + ["PORT=#{wrap_environment port}"])
environment = (engine.environment.map{ |var,env| %{#{var.upcase}="#{env}"} } + [%{PORT="#{port}"}])
app_name = "#{app}-#{name}"
app_names << app_name
%>
@@ -24,4 +24,4 @@ end
%>
[group:<%= app %>]
programs=<%= app_names.join(',') %>
programs=<%= app_names.join(',') %>

View File

@@ -23,8 +23,4 @@ class Foreman::Export::Supervisord < Foreman::Export::Base
write_file "#{location}/#{app}.conf", app_config
end
def wrap_environment env
"\"#{env}\""
end
end

View File

@@ -15,12 +15,11 @@ describe Foreman::Export::Supervisord, :fakefs do
it "exports to the filesystem" do
supervisord.export
File.read("/tmp/init/app.conf").should == example_export_file("supervisord/app.conf")
File.read("/tmp/init/app.conf").should == example_export_file("supervisord/app.conf")
end
it "cleans up if exporting into an existing dir" do
mock(FileUtils).rm("/tmp/init/app.conf")
supervisord.export
supervisord.export
end
@@ -30,8 +29,7 @@ describe Foreman::Export::Supervisord, :fakefs do
it "exports to the filesystem with concurrency" do
supervisord.export
File.read("/tmp/init/app.conf").should == example_export_file("supervisord/app-alpha-2.conf")
File.read("/tmp/init/app.conf").should == example_export_file("supervisord/app-alpha-2.conf")
end
end
@@ -46,7 +44,6 @@ describe Foreman::Export::Supervisord, :fakefs do
it "can export with alternate template files" do
supervisord.export
File.read("/tmp/init/app.conf").should == "alternate_template\n"
end
end
@@ -67,16 +64,11 @@ describe Foreman::Export::Supervisord, :fakefs do
it "can export with alternate template files" do
supervisord.export
File.read("/tmp/init/app.conf").should == "default_alternate_template\n"
end
end
context "environment export" do
it "wraps the original environment with quotes" do
supervisord.wrap_environment("slowqueue,fastqueue").should == '"slowqueue,fastqueue"'
end
it "correctly translates environment when exporting" do
File.open("/tmp/supervisord_env", "w") { |f| f.puts("QUEUE=fastqueue,slowqueue\nVERBOSE=1") }