chore: fix tests with Elixir 1.13.0.

This commit is contained in:
James Harton 2021-12-09 20:10:07 +13:00
parent f1989b7f87
commit 7ecafe6631
7 changed files with 22 additions and 19 deletions

View file

@ -1,4 +1,4 @@
use Mix.Config import Config
config :wafer, Wafer.Driver.Fake, warn: Mix.env() != :test config :wafer, Wafer.Driver.Fake, warn: Mix.env() != :test

View file

@ -12,7 +12,7 @@ defmodule WaferDLLTest do
assert Tx.complete?(tx) assert Tx.complete?(tx)
assert Rx.complete?(rx) assert Rx.complete?(rx)
assert {:ok, value} = Rx.value(rx) assert {:ok, ^value} = Rx.value(rx)
end end
def transmit(%Tx{} = tx, %Rx{} = rx) do def transmit(%Tx{} = tx, %Rx{} = rx) do

View file

@ -23,7 +23,7 @@ defmodule WaferDriverCircuits.GPIO.DispatcherTest do
:ok :ok
end) end)
assert {:reply, {:ok, conn}, _state} = assert {:reply, {:ok, _conn}, _state} =
Dispatcher.handle_call({:enable, conn, :rising}, nil, state()) Dispatcher.handle_call({:enable, conn, :rising}, nil, state())
end end
@ -37,7 +37,7 @@ defmodule WaferDriverCircuits.GPIO.DispatcherTest do
:ok :ok
end) end)
assert {:reply, {:ok, conn}, _state} = assert {:reply, {:ok, _conn}, _state} =
Dispatcher.handle_call({:enable, conn, :falling}, nil, state()) Dispatcher.handle_call({:enable, conn, :falling}, nil, state())
end end
@ -51,7 +51,7 @@ defmodule WaferDriverCircuits.GPIO.DispatcherTest do
:ok :ok
end) end)
assert {:reply, {:ok, conn}, _state} = assert {:reply, {:ok, _conn}, _state} =
Dispatcher.handle_call({:enable, conn, :both}, nil, state()) Dispatcher.handle_call({:enable, conn, :both}, nil, state())
end end
@ -63,7 +63,7 @@ defmodule WaferDriverCircuits.GPIO.DispatcherTest do
Dispatcher.handle_call({:enable, conn, :rising}, nil, state()) Dispatcher.handle_call({:enable, conn, :rising}, nil, state())
assert {:reply, {:ok, conn}, _state} = assert {:reply, {:ok, _conn}, _state} =
Dispatcher.handle_call({:disable, conn, :rising}, nil, state()) Dispatcher.handle_call({:disable, conn, :rising}, nil, state())
end end
@ -75,7 +75,7 @@ defmodule WaferDriverCircuits.GPIO.DispatcherTest do
Dispatcher.handle_call({:enable, conn, :falling}, nil, state()) Dispatcher.handle_call({:enable, conn, :falling}, nil, state())
assert {:reply, {:ok, conn}, _state} = assert {:reply, {:ok, _conn}, _state} =
Dispatcher.handle_call({:disable, conn, :falling}, nil, state()) Dispatcher.handle_call({:disable, conn, :falling}, nil, state())
end end
@ -87,7 +87,7 @@ defmodule WaferDriverCircuits.GPIO.DispatcherTest do
Dispatcher.handle_call({:enable, conn, :both}, nil, state()) Dispatcher.handle_call({:enable, conn, :both}, nil, state())
assert {:reply, {:ok, conn}, _state} = assert {:reply, {:ok, _conn}, _state} =
Dispatcher.handle_call({:disable, conn, :both}, nil, state()) Dispatcher.handle_call({:disable, conn, :both}, nil, state())
refute IR.subscribers?({Dispatcher, 1}, :both) refute IR.subscribers?({Dispatcher, 1}, :both)

View file

@ -23,7 +23,7 @@ defmodule WaferCircuits.I2CTest do
[address] [address]
end) end)
assert {:ok, %Subject{} = conn} = Subject.acquire(bus_name: busname, address: address) assert {:ok, %Subject{}} = Subject.acquire(bus_name: busname, address: address)
end end
test "when the device is not present on the bus" do test "when the device is not present on the bus" do
@ -59,8 +59,7 @@ defmodule WaferCircuits.I2CTest do
[] []
end) end)
assert {:ok, %Subject{} = conn} = assert {:ok, %Subject{}} = Subject.acquire(bus_name: busname, address: address, force: true)
Subject.acquire(bus_name: busname, address: address, force: true)
end end
test "when the bus name is not specified it returns an error" do test "when the bus name is not specified it returns an error" do

View file

@ -24,7 +24,7 @@ defmodule WaferElixirALE.I2CTest do
[address] [address]
end) end)
assert {:ok, %Subject{} = conn} = Subject.acquire(bus_name: busname, address: address) assert {:ok, %Subject{}} = Subject.acquire(bus_name: busname, address: address)
end end
test "when the device is not present on the bus" do test "when the device is not present on the bus" do
@ -62,8 +62,7 @@ defmodule WaferElixirALE.I2CTest do
[] []
end) end)
assert {:ok, %Subject{} = conn} = assert {:ok, %Subject{}} = Subject.acquire(bus_name: busname, address: address, force: true)
Subject.acquire(bus_name: busname, address: address, force: true)
end end
test "when the bus name is not specified it returns an error" do test "when the bus name is not specified it returns an error" do

View file

@ -100,7 +100,6 @@ defmodule WaferInterruptRegistryTest do
end end
test "returns false if there are no subscribers for `key` and `pin_condition`" do test "returns false if there are no subscribers for `key` and `pin_condition`" do
receiver = self()
:ok = IR.subscribe(:key, :rising, :conn, :metadata) :ok = IR.subscribe(:key, :rising, :conn, :metadata)
refute IR.subscribers?(:key, :falling) refute IR.subscribers?(:key, :falling)

View file

@ -1,12 +1,18 @@
defmodule TestUtils do defmodule TestUtils do
@moduledoc false @moduledoc false
@chars ~w[A B C D E F G H I J K L M N O P Q R S T U V W X Y Z]
def random_module_name do def random_module_name do
name = name = random_string("", 16)
16
|> :crypto.strong_rand_bytes()
|> Base.encode64(padding: false)
Module.concat(__MODULE__, name) Module.concat(__MODULE__, name)
end end
defp random_string(str, 0), do: str
defp random_string(str, count) do
"#{str}#{Enum.random(@chars)}"
|> random_string(count - 1)
end
end end