Sha256: 8216af444d6db883a26d68e6f8fdebe01f13eec1a17a43dae559a6e8b4a2b9c0

Contents?: true

Size: 1.44 KB

Versions: 7

Compression:

Stored size: 1.44 KB

Contents

$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'helper'
require 'citrin/cli'
require 'mysql2'

class TestCitrin < Test::Unit::TestCase

  def setup
    @appname = "citest" 
  end

  def teardown
    Citrin::CLI.start("remove_railsapp", @appname)
    @app = Citrin::App.new(@appname)
    begin
       # connect to the MySQL server
       dbh = Mysql2::Client.new(:host => "localhost", :username => Citrin::config['db_user'], :password => Citrin::config['db_pass'] )
       dbh.query("drop user #{@app.db_user}@localhost;");
       dbh.query("drop database #{@app.db_name};");
    rescue
    ensure
      # disconnect from server
      dbh.close if dbh
    end
  end

  should "create webserver config" do
    Citrin::CLI.start("create_webserver", @appname)
    assert File.exists?("/etc/apache2/sites-enabled/prod.#{@appname}.conf")
    `cd /var/www/rails_apps/prod/ && rails new #{@appname}`
    statuscode = `curl -sL -w "%{http_code}" "#{@appname}.$(hostname -f)" -o /dev/null`
    assert_equal "200", statuscode
  end

  should "create database" do
   @app=Citrin::CLI.start("create_database", @appname)
   begin
     # connect to the MySQL server
     dbh = Mysql2::Client.new(:host => "localhost", :username => @app.db_user, :password => @app.db_pass, :database => @app.db_name )
   rescue Mysql2::Error => e
     puts "Error message: #{e.error}"
     fail "Can't connect to created DB"
   ensure
     # disconnect from server
     dbh.close if dbh
   end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
citrin-0.1.7 test/test_citrin.rb
citrin-0.1.6 test/test_citrin.rb
citrin-0.1.5 test/test_citrin.rb
citrin-0.1.4 test/test_citrin.rb
citrin-0.1.3 test/test_citrin.rb
citrin-0.1.2 test/test_citrin.rb
citrin-0.1.1 test/test_citrin.rb