diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 73e65f7..eb3995d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,24 +14,38 @@ permissions: contents: read jobs: - build: + test: name: Build and test runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - pair: + elixir: 1.12 + otp: 24 + - pair: + elixir: 1.14 + otp: 25 + - pair: + elixir: 1.15 + otp: 26 + steps: - uses: actions/checkout@v3 - name: Set up Elixir uses: erlef/setup-beam@v1 with: - elixir-version: '1.14.3' - otp-version: '25.x' + elixir-version: ${{matrix.pair.elixir}} + otp-version: ${{matrix.pair.otp}} - name: Restore Elixir dependencies cache uses: actions/cache@v3 with: path: deps - key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} - restore-keys: ${{ runner.os }}-mix- + key: ${{ runner.os }}-mix-${{matrix.pair.elixir}}-${{matrix.pair.otp}}-${{ hashFiles('**/mix.lock') }} + restore-keys: ${{ runner.os }}-mix-${{matrix.pair.elixir}}-${{matrix.pair.otp}}- - name: Restore Cargo cache uses: actions/cache@v3 with: diff --git a/test/jsonrs_test.exs b/test/jsonrs_test.exs index a634083..025fd62 100644 --- a/test/jsonrs_test.exs +++ b/test/jsonrs_test.exs @@ -12,6 +12,10 @@ defmodule JsonrsTest do assert Jsonrs.encode!({:ok, :error}) == ~s(["ok","error"]) end + test "complicated term" do + assert Jsonrs.encode!(%{map: %{1 => "foo", "list" => [:ok, 42, -42, 42.0, 42.01, :error], tuple: {:ok, []}, atom: :atom}}) == ~s({"map":{"1":"foo","atom":"atom","tuple":["ok",[]],"list":["ok",42,-42,42.0,42.01,"error"]}}) + end + test "struct using fallback protocol" do assert Jsonrs.encode!(%Container{payload: ~T[12:00:00]}) == ~s({"payload":"12:00:00"}) end