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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,12 +1,18 @@
defmodule TestUtils do
@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
name =
16
|> :crypto.strong_rand_bytes()
|> Base.encode64(padding: false)
name = random_string("", 16)
Module.concat(__MODULE__, name)
end
defp random_string(str, 0), do: str
defp random_string(str, count) do
"#{str}#{Enum.random(@chars)}"
|> random_string(count - 1)
end
end