@@ -51,6 +51,7 @@ defmodule Livebook.FileSystem.GitTest do
51
51
52
52
describe "FileSystem.read/2" do
53
53
@ describetag init: true
54
+
54
55
test "returns an error when a nonexistent key is given" , % { file_system: file_system } do
55
56
assert FileSystem . read ( file_system , "/another_file.txt" ) ==
56
57
{ :error , "fatal: path 'another_file.txt' does not exist in 'main'" }
@@ -104,6 +105,7 @@ defmodule Livebook.FileSystem.GitTest do
104
105
105
106
describe "FileSystem.etag_for/2" do
106
107
@ describetag init: true
108
+
107
109
test "returns an error when a nonexistent key is given" , % { file_system: file_system } do
108
110
assert { :error , reason } = FileSystem . etag_for ( file_system , "/another_file.txt" )
109
111
assert reason =~ "path 'another_file.txt' does not exist in 'main'"
@@ -116,6 +118,7 @@ defmodule Livebook.FileSystem.GitTest do
116
118
117
119
describe "FileSystem.exists?/2" do
118
120
@ describetag init: true
121
+
119
122
test "returns valid response" , % { file_system: file_system } do
120
123
assert { :ok , true } = FileSystem . exists? ( file_system , "/file.txt" )
121
124
assert { :ok , false } = FileSystem . exists? ( file_system , "/another_file.txt" )
@@ -158,10 +161,27 @@ defmodule Livebook.FileSystem.GitTest do
158
161
end
159
162
160
163
describe "FileSystem.read_stream_into/2" do
161
- test "not implemented" , % { file_system: file_system } do
162
- assert_raise RuntimeError , "not implemented" , fn ->
163
- FileSystem . read_stream_into ( file_system , "/file.txt" , << >> )
164
- end
164
+ @ describetag init: true
165
+
166
+ test "returns an error when a nonexistent key is given" , % { file_system: file_system } do
167
+ assert FileSystem . read_stream_into ( file_system , "/another_file.txt" , << >> ) ==
168
+ { :error , "fatal: path 'another_file.txt' does not exist in 'main'" }
169
+ end
170
+
171
+ test "returns object contents under the given key" , % { file_system: file_system } do
172
+ assert { :ok , content } = FileSystem . read_stream_into ( file_system , "/file.txt" , << >> )
173
+ assert content =~ "git file storage works"
174
+ end
175
+
176
+ @ tag :tmp_dir
177
+ test "collects file contents into another file" , % { file_system: file_system , tmp_dir: tmp_dir } do
178
+ file_path = Path . join ( tmp_dir , "myfile.txt" )
179
+ collectable = FileSystem.File . new ( FileSystem.Local . new ( ) , file_path )
180
+
181
+ assert { :ok , % FileSystem.File { path: ^ file_path } } =
182
+ FileSystem . read_stream_into ( file_system , "/file.txt" , collectable )
183
+
184
+ assert File . read! ( file_path ) =~ "git file storage works"
165
185
end
166
186
end
167
187
0 commit comments