Sha256: bbc6eba28b2bd4845b9793c2010b30b1042a51fc27f8aa73ceb3a3f19607f46e

Contents?: true

Size: 1.28 KB

Versions: 21

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

describe AvroTurf::SchemaStore do

  it 'should add an in-memory schema' do
    schema_store = described_class.new(path: Deimos.config.schema_path)
    schema_store.load_schemas!
    found_schema = schema_store.find('MySchema', 'com.my-namespace').as_json
    expect(found_schema['name']).to eq('MySchema')
    expect(found_schema['namespace']).to eq('com.my-namespace')
    expect(found_schema['fields'].size).to eq(2)
    expect(found_schema['fields'][0]['type']['type_sym']).to eq('string')
    expect(found_schema['fields'][0]['name']).to eq('test_id')
    new_schema = {
      'namespace' => 'com.my-namespace',
      'name' => 'MyNewSchema',
      'type' => 'record',
      'doc' => 'Test schema',
      'fields' => [
        {
          'name' => 'my_id',
          'type' => 'int',
          'doc' => 'test int'
        }
      ]
    }
    schema_store.add_schema(new_schema)
    found_schema = schema_store.find('MyNewSchema', 'com.my-namespace').
      as_json
    expect(found_schema['name']).to eq('MyNewSchema')
    expect(found_schema['namespace']).to eq('com.my-namespace')
    expect(found_schema['fields'].size).to eq(1)
    expect(found_schema['fields'][0]['type']['type_sym']).to eq('int')
    expect(found_schema['fields'][0]['name']).to eq('my_id')
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
deimos-ruby-1.3.0.pre.beta5 spec/updateable_schema_store_spec.rb
deimos-ruby-1.3.0.pre.beta4 spec/updateable_schema_store_spec.rb
deimos-ruby-1.3.0.pre.beta3 spec/updateable_schema_store_spec.rb
deimos-ruby-1.3.0.pre.beta2 spec/updateable_schema_store_spec.rb
deimos-ruby-1.3.0.pre.beta1 spec/updateable_schema_store_spec.rb
deimos-ruby-1.2.0.pre.beta1 spec/updateable_schema_store_spec.rb
deimos-ruby-1.1.0.pre.beta2 spec/updateable_schema_store_spec.rb
deimos-ruby-1.1.0.pre.beta1 spec/updateable_schema_store_spec.rb
deimos-ruby-1.0.0 spec/updateable_schema_store_spec.rb
deimos-ruby-1.0.0.pre.beta26 spec/updateable_schema_store_spec.rb
deimos-ruby-1.0.0.pre.beta25 spec/updateable_schema_store_spec.rb
deimos-ruby-1.0.0.pre.beta24 spec/updateable_schema_store_spec.rb
deimos-ruby-1.0.0.pre.beta23 spec/updateable_schema_store_spec.rb
deimos-ruby-1.0.0.pre.beta22 spec/updateable_schema_store_spec.rb
deimos-kafka-1.0.0.pre.beta21 spec/updateable_schema_store_spec.rb
deimos-kafka-1.0.0.pre.beta20 spec/updateable_schema_store_spec.rb
deimos-kafka-1.0.0.pre.beta19 spec/updateable_schema_store_spec.rb
deimos-kafka-1.0.0.pre.beta18 spec/updateable_schema_store_spec.rb
deimos-kafka-1.0.0.pre.beta17 spec/updateable_schema_store_spec.rb
deimos-kafka-1.0.0.pre.beta16 spec/updateable_schema_store_spec.rb