Sha256: 50869595273f6d16369df802b2aa1b065b446338c26054ccf6cdb7d1987276fe

Contents?: true

Size: 666 Bytes

Versions: 2

Compression:

Stored size: 666 Bytes

Contents

require 'norikra/udf_spec_helper'
include Norikra::UDFSpecHelper
require 'norikra/udf/lookup' # this is your UDF definition file

# for single row UDF
describe Norikra::UDF::LookupTsv do
  udf_function Norikra::UDF::LookupTsv
  TMP_TABLE_FILE = "/tmp/lookuptest.tsv"
  
  before do
    File.open(TMP_TABLE_FILE,"w"){  |f|
      f.puts "key1\thoge"
      f.puts "key2\tfoo"
    }
  end
  
  it 'Key found' do
    expect(fcall(:lookup_tsv, TMP_TABLE_FILE, "key1","notfound")).to eql("hoge")
  end

  it 'Key not found' do 
    expect(fcall(:lookup_tsv, TMP_TABLE_FILE, "key5","notfound")).to eql("notfound")
  end

  after do
    File.unlink(TMP_TABLE_FILE)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
norikra-udf-lookup-0.0.2-java spec/lookup_spec.rb
norikra-udf-lookup-0.0.1-java spec/lookup_spec.rb