Sha256: 377ce1c8eaf584503b33dca5050d91615e649bb13bc6f7f67c9530334b8798f5

Contents?: true

Size: 1.85 KB

Versions: 13

Compression:

Stored size: 1.85 KB

Contents

require 'test_helper'

class CassandraObject::SchemaTest < CassandraObject::TestCase
  test "create_keyspace" do
    CassandraObject::Schema.create_keyspace 'Blah'

    existing_keyspace = false
    begin
      CassandraObject::Schema.create_keyspace 'Blah'
    rescue Exception => e
      existing_keyspace = true
    ensure
      CassandraObject::Schema.drop_keyspace 'Blah'
    end

    assert existing_keyspace
  end

  test "create_column_family" do
    CassandraObject::Schema.create_column_family 'TestRecords', 'compression_parameters:sstable_compression' => 'SnappyCompressor'

    begin
      CassandraObject::Schema.create_column_family 'TestRecords'
      assert false, 'TestRecords should already exist'
    rescue Exception => e
    end
  end

  test "drop_column_family" do
    CassandraObject::Schema.create_column_family 'TestCFToDrop'

    CassandraObject::Schema.drop_column_family 'TestCFToDrop'

    begin
      CassandraObject::Schema.drop_column_family 'TestCFToDrop'
      assert false, 'TestCFToDrop should not exist'
    rescue Exception => e
    end
  end

  test "create_index" do
    CassandraObject::Schema.create_column_family 'TestIndexed'

    CassandraObject::Schema.alter_column_family 'TestIndexed', "ADD id_value varchar"

    CassandraObject::Schema.add_index 'TestIndexed', 'id_value'
  end

  test "drop_index" do
    CassandraObject::Schema.create_column_family 'TestDropIndexes'

    CassandraObject::Schema.alter_column_family 'TestDropIndexes', "ADD id_value1 varchar"
    CassandraObject::Schema.alter_column_family 'TestDropIndexes', "ADD id_value2 varchar"

    CassandraObject::Schema.add_index 'TestDropIndexes', 'id_value1'
    CassandraObject::Schema.add_index 'TestDropIndexes', 'id_value2', 'special_name'

    CassandraObject::Schema.drop_index 'TestDropIndexes_id_value1_idx'
    CassandraObject::Schema.drop_index 'special_name'
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
gotime-cassandra_object-4.12.2 test/unit/schema_test.rb
gotime-cassandra_object-4.12.1 test/unit/schema_test.rb
gotime-cassandra_object-4.12.0 test/unit/schema_test.rb
gotime-cassandra_object-4.11.6 test/unit/schema_test.rb
gotime-cassandra_object-4.11.5 test/unit/schema_test.rb
gotime-cassandra_object-4.11.4 test/unit/schema_test.rb
gotime-cassandra_object-4.11.3 test/unit/schema_test.rb
gotime-cassandra_object-4.11.2 test/unit/schema_test.rb
gotime-cassandra_object-4.11.1 test/unit/schema_test.rb
gotime-cassandra_object-4.11.0 test/unit/schema_test.rb
gotime-cassandra_object-4.10.5 test/unit/schema_test.rb
gotime-cassandra_object-4.10.4 test/unit/schema_test.rb
gotime-cassandra_object-4.10.3 test/unit/schema_test.rb