Skip to content

Commit

Permalink
test: add tests for pragma optimize.
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed Oct 31, 2024
1 parent 79c943f commit 958f700
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/test_pragmas.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,46 @@ def test_set_boolean_pragma
ensure
@db.set_boolean_pragma("read_uncommitted", 0)
end

def test_optimize_with_no_args
class << @db
attr_reader :statements

def execute sql, bind_vars = [], &block
(@statements ||= []) << sql
super
end
end

@db.optimize

assert_equal(["PRAGMA optimize"], @db.statements)
end

def test_optimize_with_args
class << @db
attr_reader :statements

def execute sql, bind_vars = [], &block
(@statements ||= []) << sql
super
end
end

@db.optimize(Constants::Optimize::DEFAULT)
@db.optimize(Constants::Optimize::ANALYZE_TABLES | Constants::Optimize::LIMIT_ANALYZE)
@db.optimize(Constants::Optimize::ANALYZE_TABLES | Constants::Optimize::DEBUG)
@db.optimize(Constants::Optimize::DEFAULT | Constants::Optimize::CHECK_ALL_TABLES)

assert_equal(
[
"PRAGMA optimize=18",
"PRAGMA optimize=18",
"PRAGMA optimize=3",
"PRAGMA optimize=65554"
],
@db.statements
)
end
end
end

0 comments on commit 958f700

Please sign in to comment.