Skip to content

Commit 5482fe3

Browse files
committed
inlines DefaultGraph test helper
1 parent 6ef982a commit 5482fe3

File tree

3 files changed

+20
-23
lines changed

3 files changed

+20
-23
lines changed

test/caylir/graph_test.exs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
defmodule Caylir.GraphTest do
22
use ExUnit.Case, async: true
33

4-
alias Caylir.TestHelpers.Graphs.DefaultGraph
4+
defmodule DefaultGraph do
5+
# credo:disable-for-lines:6 Credo.Check.Readability.LargeNumbers
6+
use Caylir.Graph,
7+
otp_app: :caylir,
8+
config: [
9+
host: "localhost",
10+
port: 64210
11+
]
12+
end
513

614
defmodule LimitGraph do
715
# credo:disable-for-lines:7 Credo.Check.Readability.LargeNumbers
@@ -23,30 +31,36 @@ defmodule Caylir.GraphTest do
2331
end
2432

2533
test "invalid quads fail deleting" do
34+
{:ok, _} = start_supervised(DefaultGraph)
2635
{:error, reason} = DefaultGraph.delete(%{invalid: "quad"})
2736

2837
assert String.contains?(reason, "invalid quad")
2938
end
3039

3140
test "invalid quads fail writing" do
41+
{:ok, _} = start_supervised(DefaultGraph)
3242
{:error, reason} = DefaultGraph.write(%{invalid: "quad"})
3343

3444
assert String.contains?(reason, "invalid quad")
3545
end
3646

3747
test "invalid query string" do
48+
{:ok, _} = start_supervised(DefaultGraph)
3849
{:error, reason} = DefaultGraph.query("meh!")
3950

4051
assert String.contains?(reason, "Unexpected token")
4152
end
4253

4354
test "invalid shape query string" do
55+
{:ok, _} = start_supervised(DefaultGraph)
4456
{:error, reason} = DefaultGraph.shape("meh!")
4557

4658
assert String.contains?(reason, "Unexpected token")
4759
end
4860

4961
test "quad lifecycle", context do
62+
{:ok, _} = start_supervised(DefaultGraph)
63+
5064
quad = %{subject: "lifecycle", predicate: "for", object: to_string(context.test)}
5165
query = "graph.Vertex('lifecycle').Out('for').All()"
5266
result = [%{id: to_string(context.test)}]
@@ -58,6 +72,8 @@ defmodule Caylir.GraphTest do
5872
end
5973

6074
test "query shape", context do
75+
{:ok, _} = start_supervised(DefaultGraph)
76+
6177
quad = %{subject: "shapecycle", predicate: "for", object: to_string(context.test)}
6278
query = "graph.Vertex('shapecycle').Out('for').All()"
6379

test/helpers/graphs/default_graph.ex

Lines changed: 0 additions & 11 deletions
This file was deleted.

test/test_helper.exs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
alias Caylir.TestHelpers.Graphs
1+
alias Caylir.TestHelpers.Graphs.InetsGraph
22

33
# start fake server
44
root = String.to_charlist(__DIR__)
@@ -18,16 +18,8 @@ inets_env = [
1818
port: :httpd.info(httpd_pid)[:port]
1919
]
2020

21-
Application.put_env(:caylir, Graphs.InetsGraph, inets_env)
22-
23-
# start graphs
24-
Supervisor.start_link(
25-
[
26-
Graphs.DefaultGraph,
27-
Graphs.InetsGraph
28-
],
29-
strategy: :one_for_one
30-
)
21+
Application.put_env(:caylir, InetsGraph, inets_env)
22+
Supervisor.start_link([InetsGraph], strategy: :one_for_one)
3123

3224
# start ExUnit
3325
ExUnit.start()

0 commit comments

Comments
 (0)