Sha256: 6065f2f0e6cf70d7c4dff268b5edd2dc8e3934d6e2fdbab9f9343b3723a7a576

Contents?: true

Size: 1.63 KB

Versions: 15

Compression:

Stored size: 1.63 KB

Contents

require 'test_helper'

# Maybe TODO: Should the tests require a running redis, mongo, mysql
# instance and actually test getting, setting data?

class StorageTest < Test::Unit::TestCase
  test "mongodb connect!" do
    connection_url ='mongodb://copy:secret@localhost/copy-content'
    Copy::Storage::Mongodb.expects(:new).with(connection_url).returns(true)
    
    assert Copy::Storage.connect!(connection_url)
  end
  
  test "redis connect!" do
    connection_url ='redis://localhost:6379'
    Copy::Storage::Redis.expects(:new).with(connection_url).returns(true)
    
    assert Copy::Storage.connect!(connection_url)
  end
  
  test "mysql connect!" do
    connection_url = 'mysql://localhost/copy_content'
    Copy::Storage::Relational.expects(:new).with(connection_url).returns(true)
    
    assert Copy::Storage.connect!(connection_url)
  end
  
  test "postgres connect!" do
    connection_url = 'postgres://localhost/copy_content'
    Copy::Storage::Relational.expects(:new).with(connection_url).returns(true)
    
    assert Copy::Storage.connect!(connection_url)
  end
  
  test "sqlite connect!" do
    connection_url = 'sqlite:///path/to/copy_content.db'
    Copy::Storage::Relational.expects(:new).with(connection_url).returns(true)
    
    assert Copy::Storage.connect!(connection_url)
  end
  
  test "get and set" do
    connection_url ='redis://localhost:6379'
    Copy::Storage::Redis.expects(:new).with(connection_url).returns(stub(:get => :result1, :set => :result2))
    
    Copy::Storage.connect!(connection_url)
    assert_equal :result1, Copy::Storage.get('name')
    assert_equal :result2, Copy::Storage.set('name', 'content')
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
copy_no_dependency-0.2.0 test/storage_test.rb
copy-0.2.0 test/storage_test.rb
copy-0.1.7 test/storage_test.rb
copy-0.1.6 test/storage_test.rb
copy-0.1.5 test/storage_test.rb
copy-0.1.4 test/storage_test.rb
copy-0.1.3 test/storage_test.rb
copy-0.1.2 test/storage_test.rb
copy-0.1.1 test/storage_test.rb
copy-0.1.0 test/storage_test.rb
copy-0.0.41 test/storage_test.rb
copy-0.0.4 test/storage_test.rb
copy-0.0.3 test/storage_test.rb
copy-0.0.2 test/storage_test.rb
copy-0.0.1 test/storage_test.rb