reduce test chatter
This commit is contained in:
parent
6cc93989c0
commit
9ed9d59078
|
|
@ -13,5 +13,6 @@ class DbTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
c.send(:has_ancestry)
|
||||
assert true, "this should not connect to the database"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@ require_relative '../environment'
|
|||
# These are only valid for postgres
|
||||
class DepthVirtualTest < ActiveSupport::TestCase
|
||||
def test_depth_caching
|
||||
return unless test_virtual_column?
|
||||
assert true, "only runs for postgres and recent rails versions"
|
||||
return unless only_test_virtual_column?
|
||||
|
||||
AncestryTestDatabase.with_model :depth => 3, :width => 3, :cache_depth => :virtual do |_model, roots|
|
||||
roots.each do |lvl0_node, lvl0_children|
|
||||
|
|
@ -19,7 +20,8 @@ class DepthVirtualTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_depth_caching_after_subtree_movement
|
||||
return unless test_virtual_column?
|
||||
assert true, "only runs for postgres and recent rails versions"
|
||||
return unless only_test_virtual_column?
|
||||
|
||||
AncestryTestDatabase.with_model :depth => 6, :width => 1, :cache_depth => :virtual do |model, _roots|
|
||||
node = model.at_depth(3).first
|
||||
|
|
@ -35,7 +37,8 @@ class DepthVirtualTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_depth_scopes
|
||||
return unless test_virtual_column?
|
||||
assert true, "only runs for postgres and recent rails versions"
|
||||
return unless only_test_virtual_column?
|
||||
|
||||
AncestryTestDatabase.with_model :depth => 4, :width => 2, :cache_depth => true do |model, _roots|
|
||||
model.before_depth(2).all? { |node| assert node.depth < 2 }
|
||||
|
|
@ -47,7 +50,8 @@ class DepthVirtualTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_depth_scopes_without_depth_cache
|
||||
return unless test_virtual_column?
|
||||
assert true, "only runs for postgres and recent rails versions"
|
||||
return unless only_test_virtual_column?
|
||||
|
||||
AncestryTestDatabase.with_model :depth => 4, :width => 2 do |model, _roots|
|
||||
model.before_depth(2).all? { |node| assert node.depth < 2 }
|
||||
|
|
@ -59,7 +63,8 @@ class DepthVirtualTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_exception_when_rebuilding_depth_cache_for_model_without_depth_caching
|
||||
return unless test_virtual_column?
|
||||
assert true, "only runs for postgres and recent rails versions"
|
||||
return unless only_test_virtual_column?
|
||||
|
||||
AncestryTestDatabase.with_model do |model|
|
||||
assert_raise Ancestry::AncestryException do
|
||||
|
|
@ -69,7 +74,8 @@ class DepthVirtualTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_exception_on_unknown_depth_column
|
||||
return unless test_virtual_column?
|
||||
assert true, "only runs for postgres and recent rails versions"
|
||||
return unless only_test_virtual_column?
|
||||
|
||||
AncestryTestDatabase.with_model :cache_depth => true do |model|
|
||||
assert_raise Ancestry::AncestryException do
|
||||
|
|
@ -81,7 +87,8 @@ class DepthVirtualTest < ActiveSupport::TestCase
|
|||
# we are already testing generate and parse against static values
|
||||
# this assumes those are methods are tested and working
|
||||
def test_ancestry_depth_change
|
||||
return unless test_virtual_column?
|
||||
assert true, "only runs for postgres and recent rails versions"
|
||||
return unless only_test_virtual_column?
|
||||
|
||||
AncestryTestDatabase.with_model do |model|
|
||||
{
|
||||
|
|
@ -98,7 +105,7 @@ class DepthVirtualTest < ActiveSupport::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_virtual_column?
|
||||
def only_test_virtual_column?
|
||||
AncestryTestDatabase.postgres? && ActiveRecord.version.to_s >= "7.0"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ require_relative '../environment'
|
|||
|
||||
class MaterializedPath2Test < ActiveSupport::TestCase
|
||||
def test_ancestry_column_mp2
|
||||
assert true, "this runs if materialized path2"
|
||||
return unless AncestryTestDatabase.materialized_path2?
|
||||
|
||||
AncestryTestDatabase.with_model do |model|
|
||||
|
|
@ -37,6 +38,7 @@ class MaterializedPath2Test < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_ancestry_column_validation
|
||||
assert true, "this runs if materialized path2"
|
||||
return unless AncestryTestDatabase.materialized_path2?
|
||||
|
||||
AncestryTestDatabase.with_model do |model|
|
||||
|
|
@ -50,6 +52,7 @@ class MaterializedPath2Test < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_ancestry_column_validation_fails
|
||||
assert true, "this runs if materialized path2"
|
||||
return unless AncestryTestDatabase.materialized_path2?
|
||||
|
||||
AncestryTestDatabase.with_model do |model|
|
||||
|
|
@ -63,6 +66,7 @@ class MaterializedPath2Test < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_ancestry_column_validation_string_key
|
||||
assert true, "this runs if materialized path2"
|
||||
return unless AncestryTestDatabase.materialized_path2?
|
||||
|
||||
AncestryTestDatabase.with_model(:id => :string, :primary_key_format => /[a-z]/) do |model|
|
||||
|
|
@ -75,6 +79,7 @@ class MaterializedPath2Test < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_ancestry_column_validation_string_key_fails
|
||||
assert true, "this runs if materialized path2"
|
||||
return unless AncestryTestDatabase.materialized_path2?
|
||||
|
||||
AncestryTestDatabase.with_model(:id => :string, :primary_key_format => /[a-z]/) do |model|
|
||||
|
|
@ -87,6 +92,7 @@ class MaterializedPath2Test < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_ancestry_validation_exclude_self
|
||||
assert true, "this runs if materialized path2"
|
||||
return unless AncestryTestDatabase.materialized_path2?
|
||||
|
||||
AncestryTestDatabase.with_model do |model|
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ require_relative '../environment'
|
|||
|
||||
class MaterializedPathTest < ActiveSupport::TestCase
|
||||
def test_ancestry_column_values
|
||||
assert true, "this runs if materialized path"
|
||||
return if AncestryTestDatabase.materialized_path2?
|
||||
|
||||
AncestryTestDatabase.with_model do |model|
|
||||
|
|
@ -37,6 +38,7 @@ class MaterializedPathTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_ancestry_column_validation
|
||||
assert true, "this runs if materialized path"
|
||||
return if AncestryTestDatabase.materialized_path2?
|
||||
|
||||
AncestryTestDatabase.with_model do |model|
|
||||
|
|
@ -50,6 +52,7 @@ class MaterializedPathTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_ancestry_column_validation_fails
|
||||
assert true, "this runs if materialized path"
|
||||
return if AncestryTestDatabase.materialized_path2?
|
||||
|
||||
AncestryTestDatabase.with_model do |model|
|
||||
|
|
@ -63,6 +66,7 @@ class MaterializedPathTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_ancestry_column_validation_string_key
|
||||
assert true, "this runs if materialized path"
|
||||
return if AncestryTestDatabase.materialized_path2?
|
||||
|
||||
AncestryTestDatabase.with_model(:id => :string, :primary_key_format => /[a-z]/) do |model|
|
||||
|
|
@ -76,6 +80,7 @@ class MaterializedPathTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_ancestry_column_validation_string_key_fails
|
||||
assert true, "this runs if materialized path"
|
||||
return if AncestryTestDatabase.materialized_path2?
|
||||
|
||||
AncestryTestDatabase.with_model(:id => :string, :primary_key_format => /[a-z]/) do |model|
|
||||
|
|
@ -89,6 +94,7 @@ class MaterializedPathTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_ancestry_validation_exclude_self
|
||||
assert true, "this runs if materialized path"
|
||||
return if AncestryTestDatabase.materialized_path2?
|
||||
|
||||
AncestryTestDatabase.with_model do |model|
|
||||
|
|
|
|||
|
|
@ -121,8 +121,8 @@ class ScopesTest < ActiveSupport::TestCase
|
|||
AncestryTestDatabase.with_model(:extra_columns => {:name => :string}) do |model|
|
||||
root = model.create
|
||||
record = root.children.create
|
||||
# this should not throw an exception
|
||||
record.reload.parent.children.find_or_create_by! :name => 'abc'
|
||||
assert true, "this should not throw an exception"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -225,6 +225,7 @@ class TreeNavigationTest < ActiveSupport::TestCase
|
|||
# please create PR or issue if you have a better idea
|
||||
def test_node_before_last_save
|
||||
AncestryTestDatabase.with_model do |model|
|
||||
assert true, "this runs for integer primary keys"
|
||||
skip "only written for integer keys" unless model.primary_key_is_an_integer?
|
||||
model.delete_all
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue