mirror of
https://github.com/livebook-dev/livebook.git
synced 2024-11-15 20:37:55 +08:00
8e6558a83a
* 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>
21 lines
508 B
Elixir
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
|