# frozen_string_literal: true

require "cases/helper"

class QueryLogsFormatter < ActiveRecord::TestCase
  def test_factory_invalid_formatter
    assert_raises(ArgumentError) do
      ActiveRecord::QueryLogs::FormatterFactory.from_symbol(:non_existing_formatter)
    end
    end

  def test_sqlcommenter_key_value_separator
    formatter = ActiveRecord::QueryLogs::FormatterFactory.from_symbol(:sqlcommenter)
    assert_equal("=", formatter.key_value_separator)
  end

  def test_sqlcommenter_format_value
    formatter = ActiveRecord::QueryLogs::FormatterFactory.from_symbol(:sqlcommenter)
    assert_equal("'Joe\\'s Crab Shack'", formatter.format_value("Joe's Crab Shack"))
  end

  def test_sqlcommenter_format_value_string_coercible
    formatter = ActiveRecord::QueryLogs::FormatterFactory.from_symbol(:sqlcommenter)
    assert_equal("'1234'", formatter.format_value(1234))
  end
end

# frozen_string_literal: true

require "cases/helper"

class QueryLogsFormatter < ActiveRecord::TestCase
  def test_factory_invalid_formatter
    assert_raises(ArgumentError) do
      ActiveRecord::QueryLogs::FormatterFactory.from_symbol(:non_existing_formatter)
    end
  end

  def test_sqlcommenter_key_value_separator
    formatter = ActiveRecord::QueryLogs::FormatterFactory.from_symbol(:sqlcommenter)
    assert_equal("=", formatter.key_value_separator)
  end

  def test_sqlcommenter_format_value
    formatter = ActiveRecord::QueryLogs::FormatterFactory.from_symbol(:sqlcommenter)
    assert_equal("'Joe\\'s Crab Shack'", formatter.format_value("Joe's Crab Shack"))
  end

  def test_sqlcommenter_format_value_string_coercible
    formatter = ActiveRecord::QueryLogs::FormatterFactory.from_symbol(:sqlcommenter)
    assert_equal("'1234'", formatter.format_value(1234))
  end
end

Address `warning: mismatched indentations` at test_factory_invalid_formatter
Address `warning: mismatched indentations` at test_factory_invalid_formatter

This commit addresses the `warning: mismatched indentations` below.

```ruby
$ bundle exec ruby -w -Itest test/cases/query_logs_formatter_test.rb -n test_factory_invalid_formatter
test/cases/query_logs_formatter_test.rb:10: warning: mismatched indentations at 'end' with 'def' at 6
Using sqlite3
Run options: -n test_factory_invalid_formatter --seed 48904

.

Finished in 0.008743s, 114.3776 runs/s, 114.3776 assertions/s.
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
$
```

Follow-up #45081
