diff --git a/spec/foreman/export/upstart_spec.rb b/spec/foreman/export/upstart_spec.rb index 329273f..5a5c3cb 100644 --- a/spec/foreman/export/upstart_spec.rb +++ b/spec/foreman/export/upstart_spec.rb @@ -1,9 +1,11 @@ require "spec_helper" require "foreman/engine" require "foreman/export/upstart" +require "tmpdir" describe Foreman::Export::Upstart do - let(:engine) { Foreman::Engine.new(write_procfile) } + let(:procfile) { FileUtils.mkdir_p("/tmp/app"); write_procfile("/tmp/app/Procfile") } + let(:engine) { Foreman::Engine.new(procfile) } let(:upstart) { Foreman::Export::Upstart.new(engine) } before(:each) { load_export_templates_into_fakefs("upstart") } @@ -11,12 +13,13 @@ describe Foreman::Export::Upstart do it "exports to the filesystem" do upstart.export("/tmp/init") + p [:d, Dir["/tmp/init/**"]] - File.read("/tmp/init/foreman.conf").should == example_export_file("upstart/foreman.conf") - File.read("/tmp/init/foreman-alpha.conf").should == example_export_file("upstart/foreman-alpha.conf") - File.read("/tmp/init/foreman-alpha-1.conf").should == example_export_file("upstart/foreman-alpha-1.conf") - File.read("/tmp/init/foreman-alpha-2.conf").should == example_export_file("upstart/foreman-alpha-2.conf") - File.read("/tmp/init/foreman-bravo.conf").should == example_export_file("upstart/foreman.bravo.conf") - File.read("/tmp/init/foreman-bravo-1.conf").should == example_export_file("upstart/foreman-bravo-1.conf") + File.read("/tmp/init/app.conf").should == example_export_file("upstart/app.conf") + File.read("/tmp/init/app-alpha.conf").should == example_export_file("upstart/app-alpha.conf") + File.read("/tmp/init/app-alpha-1.conf").should == example_export_file("upstart/app-alpha-1.conf") + File.read("/tmp/init/app-alpha-2.conf").should == example_export_file("upstart/app-alpha-2.conf") + File.read("/tmp/init/app-bravo.conf").should == example_export_file("upstart/app-bravo.conf") + File.read("/tmp/init/app-bravo-1.conf").should == example_export_file("upstart/app-bravo-1.conf") end end diff --git a/spec/resources/export/upstart/app-alpha-1.conf b/spec/resources/export/upstart/app-alpha-1.conf new file mode 100644 index 0000000..a61d392 --- /dev/null +++ b/spec/resources/export/upstart/app-alpha-1.conf @@ -0,0 +1,5 @@ +start on starting app-alpha +stop on stopping app-alpha +respawn + +exec su - app -c 'cd /tmp/app; export PORT=5000; ./alpha >> /var/log/app/alpha-1.log 2>&1' diff --git a/spec/resources/export/upstart/app-alpha-2.conf b/spec/resources/export/upstart/app-alpha-2.conf new file mode 100644 index 0000000..8e677b5 --- /dev/null +++ b/spec/resources/export/upstart/app-alpha-2.conf @@ -0,0 +1,5 @@ +start on starting app-alpha +stop on stopping app-alpha +respawn + +exec su - app -c 'cd /tmp/app; export PORT=5001; ./alpha >> /var/log/app/alpha-2.log 2>&1' diff --git a/spec/resources/export/upstart/app-alpha.conf b/spec/resources/export/upstart/app-alpha.conf new file mode 100644 index 0000000..848119e --- /dev/null +++ b/spec/resources/export/upstart/app-alpha.conf @@ -0,0 +1,2 @@ +start on starting app +stop on stopping app diff --git a/spec/resources/export/upstart/app-bravo-1.conf b/spec/resources/export/upstart/app-bravo-1.conf new file mode 100644 index 0000000..83f1e59 --- /dev/null +++ b/spec/resources/export/upstart/app-bravo-1.conf @@ -0,0 +1,5 @@ +start on starting app-bravo +stop on stopping app-bravo +respawn + +exec su - app -c 'cd /tmp/app; export PORT=5100; ./bravo >> /var/log/app/bravo-1.log 2>&1' diff --git a/spec/resources/export/upstart/app-bravo.conf b/spec/resources/export/upstart/app-bravo.conf new file mode 100644 index 0000000..848119e --- /dev/null +++ b/spec/resources/export/upstart/app-bravo.conf @@ -0,0 +1,2 @@ +start on starting app +stop on stopping app diff --git a/spec/resources/export/upstart/app.conf b/spec/resources/export/upstart/app.conf new file mode 100644 index 0000000..34f2c31 --- /dev/null +++ b/spec/resources/export/upstart/app.conf @@ -0,0 +1,8 @@ +pre-start script + +bash << "EOF" + mkdir -p /var/log/app + chown -R app /var/log/app +EOF + +end script diff --git a/spec/resources/export/upstart/foreman-alpha-1.conf b/spec/resources/export/upstart/foreman-alpha-1.conf deleted file mode 100644 index 721f7fe..0000000 --- a/spec/resources/export/upstart/foreman-alpha-1.conf +++ /dev/null @@ -1,6 +0,0 @@ -start on starting foreman-alpha -stop on stopping foreman-alpha -respawn - -chdir /Users/david/Code/foreman -exec su foreman -c 'export PORT=5000; ./alpha >> /var/log/foreman/alpha-1.log 2>&1' diff --git a/spec/resources/export/upstart/foreman-alpha-2.conf b/spec/resources/export/upstart/foreman-alpha-2.conf deleted file mode 100644 index 576c3b4..0000000 --- a/spec/resources/export/upstart/foreman-alpha-2.conf +++ /dev/null @@ -1,6 +0,0 @@ -start on starting foreman-alpha -stop on stopping foreman-alpha -respawn - -chdir /Users/david/Code/foreman -exec su foreman -c 'export PORT=5001; ./alpha >> /var/log/foreman/alpha-2.log 2>&1' diff --git a/spec/resources/export/upstart/foreman-alpha.conf b/spec/resources/export/upstart/foreman-alpha.conf deleted file mode 100644 index dac499c..0000000 --- a/spec/resources/export/upstart/foreman-alpha.conf +++ /dev/null @@ -1,2 +0,0 @@ -start on starting foreman -stop on stopping foreman diff --git a/spec/resources/export/upstart/foreman-bravo-1.conf b/spec/resources/export/upstart/foreman-bravo-1.conf deleted file mode 100644 index 4542dfc..0000000 --- a/spec/resources/export/upstart/foreman-bravo-1.conf +++ /dev/null @@ -1,6 +0,0 @@ -start on starting foreman-bravo -stop on stopping foreman-bravo -respawn - -chdir /Users/david/Code/foreman -exec su foreman -c 'export PORT=5100; ./bravo >> /var/log/foreman/bravo-1.log 2>&1' diff --git a/spec/resources/export/upstart/foreman.bravo.conf b/spec/resources/export/upstart/foreman.bravo.conf deleted file mode 100644 index dac499c..0000000 --- a/spec/resources/export/upstart/foreman.bravo.conf +++ /dev/null @@ -1,2 +0,0 @@ -start on starting foreman -stop on stopping foreman diff --git a/spec/resources/export/upstart/foreman.conf b/spec/resources/export/upstart/foreman.conf deleted file mode 100644 index de12c5c..0000000 --- a/spec/resources/export/upstart/foreman.conf +++ /dev/null @@ -1,8 +0,0 @@ -pre-start script - -bash << "EOF" - mkdir -p /var/log/foreman - chown -R foreman /var/log/foreman -EOF - -end script