core: TestData helper
This commit is contained in:
parent
1222a0d728
commit
7c4218176b
3 changed files with 22 additions and 2 deletions
14
test/support/test_data.ex
Normal file
14
test/support/test_data.ex
Normal file
|
@ -0,0 +1,14 @@
|
|||
defmodule RDF.TestData do
|
||||
|
||||
@dir Path.join(File.cwd!, "test/data/")
|
||||
def dir, do: @dir
|
||||
|
||||
def file(name) do
|
||||
if (path = Path.join(@dir, name)) |> File.exists? do
|
||||
path
|
||||
else
|
||||
raise "Test data file '#{name}' not found"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1 +1,7 @@
|
|||
ExUnit.start()
|
||||
|
||||
with {:ok, files} = File.ls("./test/support") do
|
||||
Enum.each files, fn(file) ->
|
||||
Code.require_file "support/#{file}", __DIR__
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,12 +3,12 @@ defmodule RDF.NTriples.ReaderTest do
|
|||
|
||||
doctest RDF.NTriples.Reader
|
||||
|
||||
alias RDF.{Graph}
|
||||
alias RDF.{Graph, TestData}
|
||||
|
||||
defmodule EX, do: use RDF.Vocabulary, base_uri: "http://example.org/#"
|
||||
defmodule P, do: use RDF.Vocabulary, base_uri: "http://www.perceive.net/schemas/relationship/"
|
||||
|
||||
@w3c_ntriples_test_suite Path.join(File.cwd!, "test/data/N-TRIPLES-TESTS")
|
||||
@w3c_ntriples_test_suite Path.join(TestData.dir, "N-TRIPLES-TESTS")
|
||||
|
||||
test "an empty string is deserialized to an empty graph" do
|
||||
assert RDF.NTriples.Reader.read!("") == Graph.new
|
||||
|
|
Loading…
Reference in a new issue