-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapplication_test.exs
More file actions
43 lines (35 loc) · 1.22 KB
/
Copy pathapplication_test.exs
File metadata and controls
43 lines (35 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# SPDX-License-Identifier: PMPL-1.0-or-later
# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
defmodule BojRest.ApplicationTest do
use ExUnit.Case, async: true
alias BojRest.Application, as: App
describe "parse_bind_ip/1" do
test "parses IPv4 loopback" do
assert App.parse_bind_ip("127.0.0.1") == {127, 0, 0, 1}
end
test "parses IPv4 all-interfaces" do
assert App.parse_bind_ip("0.0.0.0") == {0, 0, 0, 0}
end
test "parses IPv6 loopback" do
assert App.parse_bind_ip("::1") == {0, 0, 0, 0, 0, 0, 0, 1}
end
test "parses IPv6 all-interfaces" do
assert App.parse_bind_ip("::") == {0, 0, 0, 0, 0, 0, 0, 0}
end
test "raises ArgumentError on invalid input" do
assert_raise ArgumentError, ~r/not a valid IPv4 or IPv6 address/, fn ->
App.parse_bind_ip("not-an-ip")
end
end
test "raises ArgumentError on empty string" do
assert_raise ArgumentError, ~r/not a valid IPv4 or IPv6 address/, fn ->
App.parse_bind_ip("")
end
end
test "error message names the offending value" do
assert_raise ArgumentError, ~r/garbage/, fn ->
App.parse_bind_ip("garbage")
end
end
end
end