Sha256: a72716b9d7593c95a658f6269e6093872996c50aa06c057c01fc2480752b7066

Contents?: true

Size: 1.66 KB

Versions: 3

Compression:

Stored size: 1.66 KB

Contents

#!/usr/bin/env ruby

require './TestSetup'
require 'test/unit'
require 'rubygems'
require 'rubyfb'

include Rubyfb

class BlobTest < Test::Unit::TestCase
   CURDIR      = "#{Dir.getwd}"
   DB_FILE     = "#{CURDIR}#{File::SEPARATOR}blob_unit_test.fdb"
   TXT_FILE    = "#{CURDIR}#{File::SEPARATOR}data.txt"
   DATA        = "aasdfjakhdsfljkashdfslfhaslhasyhfawyufalwuhlhsdlkfhasljlkshflalksjhasjhalsjhdf\nasdflkajshdfjkahsdfjajdfalsdfasdf\nasdfasdfasdkljfhajdfhkjasdfagdsflalkjfgagsdflasdf\nasdfasdfasdf"

   def setup
      puts "#{self.class.name} started." if TEST_LOGGING
      # Remove existing database files.
      @database = Database.new(DB_FILE)
      if File.exist?(DB_FILE)
         @database.drop(DB_USER_NAME, DB_PASSWORD)
      end
      Database.create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
   end

   def teardown
      # Remove existing database files.
      if File.exist?(DB_FILE)
         @database.drop(DB_USER_NAME, DB_PASSWORD)
      end

      puts "#{self.class.name} finished." if TEST_LOGGING
   end

   def test01
      d = nil
      @database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
         cxn.execute_immediate('create table blob_test (data blob sub_type 0)')
         cxn.start_transaction do |tx|

            s = Statement.new(cxn, tx, 'INSERT INTO BLOB_TEST VALUES(?)', 3)
            s.execute_for([DATA])
            
            # Perform a select of the value inserted.
            r = cxn.execute('SELECT * FROM BLOB_TEST', tx)
            d = r.fetch
            
            assert_equal(d[0].to_s, DATA)

            # Clean up.
            s.close
            r.close
         end
         cxn.execute_immediate('DROP TABLE BLOB_TEST')
      end
   end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubyfb-0.5.7 test/BlobTest.rb
rubyfb-0.5.6 test/BlobTest.rb
rubyfb-0.5.5 test/BlobTest.rb