Class: FakeConfluentSchemaRegistryServer

Inherits:
Object
  • Object
show all
Includes:
AvroTurf::Test::FakeServer
Defined in:
lib/avro_turf/test/fake_confluent_schema_registry_server.rb

Constant Summary collapse

QUALIFIED_SUBJECT =
/
  :(?<context>\.[^:]*)
  :(?<subject>.*)
/x
DEFAULT_CONTEXT =
"."
SUBJECTS =
Hash.new { |hash, key| hash[key] = Hash.new { [] } }
SCHEMAS =
Hash.new { |hash, key| hash[key] = [] }
CONFIGS =
{}
SUBJECT_NOT_FOUND =
{error_code: 40401, message: "Subject not found"}.to_json.freeze
VERSION_NOT_FOUND =
{error_code: 40402, message: "Version not found"}.to_json.freeze
SCHEMA_NOT_FOUND =
{error_code: 40403, message: "Schema not found"}.to_json.freeze
DEFAULT_GLOBAL_CONFIG =
{"compatibility" => "BACKWARD"}.freeze

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from AvroTurf::Test::FakeServer

included

Class Attribute Details

.global_configObject (readonly)

Returns the value of attribute global_config.



24
25
26
# File 'lib/avro_turf/test/fake_confluent_schema_registry_server.rb', line 24

def global_config
  @global_config
end

Class Method Details

.clearObject



164
165
166
167
168
169
# File 'lib/avro_turf/test/fake_confluent_schema_registry_server.rb', line 164

def self.clear
  SUBJECTS.clear
  SCHEMAS.clear
  CONFIGS.clear
  @global_config = DEFAULT_GLOBAL_CONFIG.dup
end

Instance Method Details

#global_configObject



40
41
42
# File 'lib/avro_turf/test/fake_confluent_schema_registry_server.rb', line 40

def global_config
  self.class.global_config
end

#parse_configObject



35
36
37
38
# File 'lib/avro_turf/test/fake_confluent_schema_registry_server.rb', line 35

def parse_config
  request.body.rewind
  JSON.parse(request.body.read)
end

#parse_schemaObject

Helper methods (previously in Sinatra helpers block)



28
29
30
31
32
33
# File 'lib/avro_turf/test/fake_confluent_schema_registry_server.rb', line 28

def parse_schema
  request.body.rewind
  JSON.parse(request.body.read).fetch("schema").tap do |schema|
    Avro::Schema.parse(schema)
  end
end