Sha256: 1f99497bbab6d9d177fcc4c93bf38d33416499589a3a296a21e4ba3c23d06ff0

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

require "prepare_embulk"
require "embulk/parser/fixed"
require "embulk/data_source"


module Embulk
  module Parser
    class FixedTest < Test::Unit::TestCase

      class TestProcessLine < self

        def test_foo
          mock(page_builder).add(["eka", "Toka", "Kolmas", "Neljas"])
          line = "ekaTokaKolmas Neljas"
          plugin.send(:process_line, line)
        end

        def plugin
         @plugin ||= Fixed.new(DataSource[task], schema, page_builder)
        end

        def page_builder
          @page_builder ||= Object.new
        end

        def task
          {
            "decoder" => {"Charset" => "UTF-8", "Newline" => "CRLF"},
            "schema" => columns,
            "strip_whitespace" => true,
          }
        end

        def columns
          [
            {"name" => "foo", "type" => :string, "pos" => "0..2"},
            {"name" => "bar", "type" => :string, "pos" => "3..6"},
            {"name" => "baz", "type" => :string, "pos" => "7..12"},
            {"name" => "qux", "type" => :string, "pos" => "14..19"},
          ]
        end

        def schema
          columns.map do |column|
            Column.new(nil, column["name"], column["type"].to_sym)
          end
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
embulk-parser-fixed-0.1.0 test/embulk/parser/test_fixed.rb