Sha256: f16607036eb673798a5e0404b2d8ffe597a012e099cf69c58d09038beeb82087

Contents?: true

Size: 1.96 KB

Versions: 3

Compression:

Stored size: 1.96 KB

Contents

require 'spec/spec_helper'

describe Upstart::Exporter::Templates do
  describe ".app" do
    it "should generate a valid app config" do

      conf = <<-HEREDOC
start on 12
stop on 13

pre-start script

bash << "EOF"
  mkdir -p /var/log/SOMEAPP
  chown -R SOMEUSER /var/log/SOMEAPP
  chgrp -R SOMEGROUP /var/log/SOMEAPP
  chmod -R g+w /var/log/SOMEAPP
EOF

end script
HEREDOC

      expect(described_class.app(
        :run_user => 'SOMEUSER',
        :run_group => 'SOMEGROUP',
        :app_name => 'SOMEAPP',
        :start_on => '12',
        :stop_on => '13'
      )).to eq(conf)
    end
  end

  describe ".helper" do
    it "should generate a valid helper script" do

      conf = <<-HEREDOC
#!/bin/bash

[[ -r /etc/profile.d/rbenv.sh ]] && source /etc/profile.d/rbenv.sh

SOME COMMAND
HEREDOC

      expect(described_class.helper('cmd' => 'SOME COMMAND')).to eq(conf)
    end
  end


  describe ".helper" do
    it "should generate a valid upstart script for a single command" do

      conf = <<-HEREDOC
start on starting SOMEAPP
stop on stopping SOMEAPP
respawn
respawn limit 5 10
kill timeout 24

script
  touch /var/log/SOMEAPP/SOMECMD.log
  chown SOMEUSER /var/log/SOMEAPP/SOMECMD.log
  chgrp SOMEGROUP /var/log/SOMEAPP/SOMECMD.log
  chmod g+w /var/log/SOMEAPP/SOMECMD.log
  exec sudo -u SOMEUSER /bin/sh HELPERPATH >> /var/log/SOMEAPP/SOMECMD.log 2>&1
end script
HEREDOC

      expect(described_class.command(:run_user => 'SOMEUSER',
                              :run_group => 'SOMEGROUP',
                              :app_name => 'SOMEAPP',
                              :cmd_name => 'SOMECMD',
                              :respawn => 'respawn',
                              :respawn_limit => 'respawn limit 5 10',
                              :start_on => 'starting SOMEAPP',
                              :stop_on => 'stopping SOMEAPP',
                              :kill_timeout => 24,
                              :helper_cmd_conf => 'HELPERPATH')).to eq(conf)
    end
  end



end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
upstart-exporter-2.1.5 spec/lib/upstart-exporter/templates_spec.rb
upstart-exporter-2.1.4 spec/lib/upstart-exporter/templates_spec.rb
upstart-exporter-2.1.3 spec/lib/upstart-exporter/templates_spec.rb