From 9eb884ef7f0d06a8c0398c67eeb9e72318adc3c2 Mon Sep 17 00:00:00 2001 From: ruslandoga <67764432+ruslandoga@users.noreply.github.com> Date: Fri, 12 Jan 2024 10:56:06 +0900 Subject: [PATCH] test latest clickhouse by default, but include Plausible-specific version in the matrix --- .github/workflows/test.yml | 13 ++++++++++--- test/ch/connection_test.exs | 5 +++-- test/ch/stream_test.exs | 11 +++++------ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 06c3646..d784cfb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,17 +16,24 @@ jobs: matrix: elixir: ["1.14", "1.15", "1.16"] otp: ["25", "26"] - clickhouse: ["23.3.7.5", "latest"] + clickhouse: ["latest"] timezone: ["UTC"] include: - elixir: "1.16" otp: "26" - clickhouse: "23.3.7.5" + clickhouse: "latest" timezone: "Europe/Berlin" + # Plausible + # - https://github.com/plausible/analytics/blob/master/.tool-versions + # - https://github.com/plausible/analytics/blob/master/.github/workflows/elixir.yml + - elixir: "1.16.0" + otp: "26.2.1" + clickhouse: "23.3.7.5" + timezone: "UTC" services: clickhouse: - image: clickhouse/clickhouse-server:${{ matrix.clickhouse }}-alpine + image: clickhouse/clickhouse-server:${{ matrix.clickhouse }} ports: - 8123:8123 env: diff --git a/test/ch/connection_test.exs b/test/ch/connection_test.exs index c045756..55c998a 100644 --- a/test/ch/connection_test.exs +++ b/test/ch/connection_test.exs @@ -1282,8 +1282,9 @@ defmodule Ch.ConnectionTest do assert {:error, %Ch.Error{code: 81} = error} = Ch.query(conn, "select 1 + 1", _params = [], database: "no-db") - assert Exception.message(error) =~ - "Code: 81. DB::Exception: Database `no-db` doesn't exist. (UNKNOWN_DATABASE)" + assert Exception.message(error) =~ "Code: 81." + assert Exception.message(error) =~ "`no-db`" + assert Exception.message(error) =~ "(UNKNOWN_DATABASE)" end test "can provide custom database", %{conn: conn} do diff --git a/test/ch/stream_test.exs b/test/ch/stream_test.exs index 7d0fa84..8c8292f 100644 --- a/test/ch/stream_test.exs +++ b/test/ch/stream_test.exs @@ -10,20 +10,19 @@ defmodule Ch.StreamTest do test "emits %Ch.Result{}", %{conn: conn} do count = 1_000_000 - assert [%Result{command: :select, data: header} | rest] = + assert [%Result{command: :select, data: header} | _rest] = + results = DBConnection.run(conn, fn conn -> conn |> Ch.stream("select * from numbers({count:UInt64})", %{"count" => 1_000_000}) |> Enum.into([]) end) - assert header == [<<1, 6, "number", 6, "UInt64">>] + assert [<<1, 6, "number", 6, "UInt64">> | _] = header - decoded = - Enum.flat_map(rest, fn %Result{data: data} -> - data |> IO.iodata_to_binary() |> RowBinary.decode_rows([:u64]) - end) + decoded = results |> Enum.map(& &1.data) |> IO.iodata_to_binary() |> RowBinary.decode_rows() + assert [[0], [1], [2] | _] = decoded assert length(decoded) == count end