Sha256: 09a772b9995f42089996ad8ec42cf635726ea8410e6e0a746ed34e315871dda7

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

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

describe 'db2s3' do
  def load_schema
    `cat '#{File.dirname(__FILE__) + '/mysql_schema.sql'}' | mysql -u #{DBConfig[:user]} #{DBConfig[:database]}`
  end

  def drop_schema
    `cat '#{File.dirname(__FILE__) + '/mysql_drop_schema.sql'}' | mysql -u #{DBConfig[:user]} #{DBConfig[:database]}`
  end

  class Person < ActiveRecord::Base
  end

  it 'can save and restore a backup to S3' do
    db2s3 = DB2S3.new
    load_schema
    Person.create!(:name => "Baxter")
    db2s3.full_backup
    drop_schema
    db2s3.restore
    Person.find_by_name("Baxter").should_not be_nil
  end

  it 'provides estimated metrics' do
    db2s3 = DB2S3.new
    # 1 GB DB
    db2s3.stub!(:dump_db).and_return(stub("dump file", :size => 1024 * 1024 * 1024))
    metrics = db2s3.metrics
    metrics.should == {
      :storage_cost => 0.15, # 15c/GB-Month, we're only storing one backup
      :transfer_cost => 3.0, # 10c/GB-Month * 30 backups
      :db_size       => 1024 * 1024 * 1024, # 1 GB
      :total_cost    => 3.15,
      :full_backups_per_month => 30 # Default 1 backup/day
    }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xaviershay-db2s3-0.2 spec/db2s3_spec.rb