Sha256: 44b7e65cc9217552144dcac752937c01623075d81a6af9057322af3c8ed96429

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 KB

Contents

require_relative "../test_helper"

module Unit
  class TestUtils < MiniTest::Test

    describe Clickhouse::Utils do
      describe ".normalize_url" do
        describe "when passing scheme" do
          it "returns the passed url" do
            assert_equal "paul://engel", Clickhouse::Utils.normalize_url("paul://engel")
          end
        end

        describe "when not passing scheme" do
          it "prepends the default scheme" do
            assert_equal "http://engel", Clickhouse::Utils.normalize_url("engel")
          end
        end
      end

      describe ".extract_format" do
        describe "when not having a format" do
          it "returns the query and nil as format" do
            assert_equal ["SELECT 1", nil], Clickhouse::Utils.extract_format("SELECT 1")
          end
        end

        it "strips the query" do
          assert_equal ["SELECT 1", nil], Clickhouse::Utils.extract_format("SELECT 1     ")
        end

        it "extracts the format from the query" do
          assert_equal ["SELECT 1", "SomeFormat"], Clickhouse::Utils.extract_format("SELECT 1 FORMAT SomeFormat")
        end
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
ch-client-0.0.1 test/unit/test_utils.rb
clickhouse-0.1.10 test/unit/test_utils.rb
clickhouse-0.1.9 test/unit/test_utils.rb
clickhouse-0.1.8 test/unit/test_utils.rb