Commit 9f276513 authored by Ohad Dahan's avatar Ohad Dahan

Added 2 tests, issues with DateTime type comparions

parent 07b09817
#!/usr/bin/env ruby
$: << File.expand_path("../test", __dir__)
require "bundler/setup"
require "rails/plugin/test"
......@@ -6,7 +6,6 @@ module Nativepluck
attr_accessor :original_type_map_for_results, :original_type_map_for_queries
end
def self.included(klass)
klass.extend(ClassMethods)
@nativepluck_type_map_for_results = PG::BasicTypeMapForResults.new ActiveRecord::Base.connection.raw_connection
......
require 'test_helper'
class GenericmodelTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
test 'pluck_each_attribute' do
failed = []
Genericmodel.attribute_types.each do |attr_name, attr_type|
pluck = Genericmodel.order(id: :asc).pluck(attr_name)
nativepluck = Genericmodel.nativepluck(attr_name, order: {id: :asc} )
failed << attr_name if pluck != nativepluck
end
assert(failed.empty?, "#{__method__}:: pluck != nativepluck for attributes : #{failed.join(', ')}")
end
test 'pluck_permutations' do
LIMIT = 100
failed = []
Genericmodel.attribute_names.permutation(2).each do |attrs|
pluck = Genericmodel.limit(100).order(id: :asc).pluck(*attrs)
nativepluck = Genericmodel.nativepluck(*attrs, order: {id: :asc} , limit: LIMIT)
failed << attrs if pluck != nativepluck
end
assert(failed.empty?, "#{__method__}:: pluck != nativepluck for attributes : #{failed.join(', ')}")
end
end
......@@ -2,3 +2,24 @@ $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
require "nativepluck"
require "minitest/autorun"
# Configure Rails Environment
ENV["RAILS_ENV"] = "test"
require_relative "../test/dummy/config/environment"
ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)]
require "rails/test_help"
# Filter out Minitest backtrace while allowing backtrace from other libraries
# to be shown.
Minitest.backtrace_filter = Minitest::BacktraceFilter.new
require "rails/test_unit/reporter"
Rails::TestUnitReporter.executable = 'bin/test'
# Load fixtures from the engine
if ActiveSupport::TestCase.respond_to?(:fixture_path=)
ActiveSupport::TestCase.fixture_path = File.expand_path("fixtures", __dir__)
ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
ActiveSupport::TestCase.file_fixture_path = ActiveSupport::TestCase.fixture_path + "/files"
ActiveSupport::TestCase.fixtures :all
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment