livebook/test/support/test_helpers.ex
Jonatan Kłosko 8e6558a83a
Introduce file system abstraction and an S3 implementation (#492)
* Introduce file system abstraction and an S3 implementation

* Support arbitrary absolute paths and delegate resolution to file system

* Remove accidental notebook file

* Apply suggestions from code review

Co-authored-by: José Valim <jose.valim@dashbit.co>

* Apply review comments

* Add missing path assertions

* Apply review comments

* Fix test saving notebook in project root

Co-authored-by: José Valim <jose.valim@dashbit.co>
2021-08-13 21:17:43 +02:00

21 lines
508 B
Elixir

defmodule Livebook.TestHelpers do
@moduledoc false
@doc """
Creates file structure according to the given specification.
"""
def create_tree!(path, items) do
for {name, content} <- items do
child_path = Path.join(path, to_string(name))
case content do
items when is_list(items) ->
File.mkdir!(child_path)
create_tree!(child_path, items)
content when is_binary(content) ->
File.write!(child_path, content)
end
end
end
end