avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fo...@apache.org
Subject [avro] branch master updated: AVRO-1989: Ruby schema validation should use bytesize in error msg (#451)
Date Tue, 12 Feb 2019 15:55:15 GMT
This is an automated email from the ASF dual-hosted git repository.

fokko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/master by this push:
     new c62a8f9  AVRO-1989: Ruby schema validation should  use bytesize in error msg (#451)
c62a8f9 is described below

commit c62a8f9d11c85c18a9df1f28d23fe0396f7766b9
Author: Fokko Driesprong <fokko@driesprong.frl>
AuthorDate: Tue Feb 12 16:55:09 2019 +0100

    AVRO-1989: Ruby schema validation should  use bytesize in error msg (#451)
    
    * AVRO-1989: Ruby schema validation should use bytesize in error msg
    
    * AVRO-1989: Add a test to verify the behaviour
    
    * AVRO-1989: Add a test to verify the behaviour
---
 lang/ruby/lib/avro/schema_validator.rb  | 2 +-
 lang/ruby/test/test_schema_validator.rb | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/lang/ruby/lib/avro/schema_validator.rb b/lang/ruby/lib/avro/schema_validator.rb
index 28022a8..485092c 100644
--- a/lang/ruby/lib/avro/schema_validator.rb
+++ b/lang/ruby/lib/avro/schema_validator.rb
@@ -149,7 +149,7 @@ module Avro
       end
 
       def fixed_string_message(size, datum)
-        "expected fixed with size #{size}, got \"#{datum}\" with size #{datum.size}"
+        "expected fixed with size #{size}, got \"#{datum}\" with size #{datum.bytesize}"
       end
 
       def enum_message(symbols, datum)
diff --git a/lang/ruby/test/test_schema_validator.rb b/lang/ruby/test/test_schema_validator.rb
index c4759da..9b74d61 100644
--- a/lang/ruby/test/test_schema_validator.rb
+++ b/lang/ruby/test/test_schema_validator.rb
@@ -110,6 +110,13 @@ class TestSchema < Test::Unit::TestCase
     assert_failed_validation('at . expected fixed with size 3, got null') do
       validate_simple!(schema, nil)
     end
+
+    assert_failed_validation("at . expected fixed with size 3, got \"a\u2014b\" with size
5") do
+      validate!(schema, "a\u2014b")
+    end
+    assert_failed_validation("at . expected fixed with size 3, got \"a\u2014b\" with size
5") do
+      validate_simple!(schema, "a\u2014b")
+    end
   end
 
   def test_original_validate_nil


Mime
View raw message