Sha256: 66fd065f7ef3772a80717e3b5d132c5fe75e83b0f900ed96fe2f7c18e7be1fbb

Contents?: true

Size: 1.59 KB

Versions: 2

Compression:

Stored size: 1.59 KB

Contents

require File.dirname(__FILE__) + '/test_helper'

class TransferTest < Test::Unit::TestCase
  def setup
    @path = "/tmp/astrovan.#{Time.now.to_i}"
    @from = nil
    @to = nil
    super
  end

  def teardown
    system "rm -rf #{@path}"
    system "rm -rf #{@from}" if @from
    system "rm -rf #{@to}" if @to
    super
  end

  def test_should_put_data_into_file
    data = Time.now.utc.to_s
    @to = "#{@path}.to"
    using 'astrovan.local', :password => ENV['PASSWORD'], :data => data, :to => @to do
      put data, :to => to
    end
    assert_equal data, File.open(@to) { |f| f.gets.chomp }
  end

  def test_should_upload_file
    data = Time.now.utc.to_s
    @from = "#{@path}.from"
    @to = "#{@path}.to"
    File.open(@from, "w") { |f| f.puts data }
    using 'astrovan.local', :password => ENV['PASSWORD'], :from => @from, :to => @to do
      upload from, :to => to
    end
    assert_equal data, File.open(@to) { |f| f.gets.chomp }
  end

  def test_should_render_yaml
    common = {
      'adapter' => 'mysql',
      'username' => 'root',
      'password' => 'p@$$w0rd',
      'host' => '/var/run/mysqld/mysqld.sock',
      'socket' => '/tmp/mysql.sock'
    }

    data = {
      'development' => { 'database' => 'development_db' }.merge(common),
      'test' => { 'database' => 'test_db' }.merge(common),
      'production' => { 'database' => 'production_db' }.merge(common)
    }
    @to = "#{@path}.yml"

    using 'astrovan.local', :password => ENV['PASSWORD'], :data => data, :to => @to do
      render :yaml => data, :to => to
    end
    assert_equal data, File.open(@to) { |f| YAML.load(f) }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sbfaulkner-astrovan-0.5.9 test/transfer_test.rb
sbfaulkner-astrovan-0.6.0 test/transfer_test.rb