Class Uttk::Strategies::SqlQuery
In: lib/uttk/strategies/SqlQuery.rb
Parent: Strategy

This strategy manage SQL base tests. It use unit testing (EXCEPT ALL query) for checking results. To use it, you need to have dbi installed on your test system and have a database with these things:

  * a test schema (MY)
  * a reference schema (REF)

After that you have just to write all queries that you want to test. Queries will be called on each schema by applying a delta operation:

   (REF ` MY) U (MY ` REF).

In queries, %s will be replaced by given schemas.

Methods

Included Modules

Concrete

Protected Instance methods

[Source]

# File lib/uttk/strategies/SqlQuery.rb, line 63
      def assertion
        unless @delta.nil?
          @log.diff_output = @delta
          fail('Delta not empty')
        end
        super
      end

Methods

[Source]

# File lib/uttk/strategies/SqlQuery.rb, line 35
      def prologue
        super
        if @@db.nil?
          require 'dbi'
          # Check if driver is available
          if DBI.available_drivers.to_s !~ /#@driver/
            raise_error("Unknown driver: #@driver")
          else
            # Start DB connection
            @@db = DBI.connect("DBI:#@driver:host=#@host;database=#@database",
                               @user, @passwd)
          end
        end
      end

[Source]

# File lib/uttk/strategies/SqlQuery.rb, line 52
      def run_impl
        @delta = nil
        begin
          @delta = perform_delta
        rescue DBI::DatabaseError => ex
          fail(ex)
        end
      end

[Validate]