From 6ac275818dcec736e8dcfd2e52aa23f6ed0e8b36 Mon Sep 17 00:00:00 2001
From: Alexander Kreft <akreft@trineo.org>
Date: Thu, 26 Aug 2021 08:44:03 +0000
Subject: [PATCH] TST: Test retrieve and download File by ID

---
 test/runtests.jl | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/test/runtests.jl b/test/runtests.jl
index 48d1e01..a34010b 100644
--- a/test/runtests.jl
+++ b/test/runtests.jl
@@ -23,6 +23,7 @@
 
 using Test
 using Logging
+using UUIDs
 # first try and load a local CaosDB installation; if that fails,
 # set-up CaosDB.jl with repo and branch specified in
 # `CaosDBIntegrationTests`. The latter is mainly useful for running
@@ -193,4 +194,27 @@ end
 
     end
 
+    @testset "Test retrieve and download File by ID" begin
+        #a file TestFile is needed on the server!
+        ent_with_name = execute_query("FIND TestFile")
+        path = string(pwd(), "/", string(uuid4()))
+        single_insert_transaction = create_transaction()
+        add_retrieve_and_download_file_by_id(
+            single_insert_transaction,
+            get_id(ent_with_name[1]),
+            path,
+        )
+        execute(single_insert_transaction)
+        results = get_results(single_insert_transaction)
+
+        @test length(results) == 1
+        @test has_errors(results[1]) == false
+        @test get_id(results[1]) != ""
+        @test isfile(path) == true
+
+        #cleanup
+        rm(path)
+
+    end
+
 end
-- 
GitLab