From d66af3bb23ff5b8bdadbb589fe36238b6c0b1341 Mon Sep 17 00:00:00 2001
From: Samuel Gaist <samuel.gaist@idiap.ch>
Date: Thu, 5 Nov 2020 18:00:15 +0100
Subject: [PATCH] [test][prefix] Make all databases root folder point to a
 valid location

This will allow the docker tests to more easily setup and
cleanup its content.

While the folder is not used as these databases are generative
only, docker will create it anyway as mounting a non-exisiting
folder will trigger its creation with the daemon ownership
applied.
---
 beat/backend/python/test/__init__.py                          | 4 ++++
 beat/backend/python/test/prefix/databases/crash/1.json        | 2 +-
 .../python/test/prefix/databases/duplicate_key_error/1.json   | 2 +-
 beat/backend/python/test/prefix/databases/integers_db/1.json  | 2 +-
 beat/backend/python/test/prefix/databases/integers_db/2.json  | 2 +-
 .../python/test/prefix/databases/integers_db_env/1.json       | 2 +-
 .../python/test/prefix/databases/integers_db_env/2.json       | 2 +-
 .../python/test/prefix/databases/python_keyword/1.json        | 2 +-
 beat/backend/python/test/prefix/databases/syntax_error/1.json | 2 +-
 .../python/test/prefix/databases/with_parameters/1.json       | 2 +-
 .../python/test/prefix/databases/with_parameters/2.json       | 2 +-
 11 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/beat/backend/python/test/__init__.py b/beat/backend/python/test/__init__.py
index 9b5a7da..3de6ae2 100644
--- a/beat/backend/python/test/__init__.py
+++ b/beat/backend/python/test/__init__.py
@@ -36,3 +36,7 @@
 import pkg_resources
 
 prefix = pkg_resources.resource_filename(__name__, "prefix")
+
+# This variable should be used to generate the appropriate folder when dealing with
+# docker execution.
+BBP_DATABASE_ROOT_FOLDER = "/tmp/beat_backend_python_test"  # nosec
diff --git a/beat/backend/python/test/prefix/databases/crash/1.json b/beat/backend/python/test/prefix/databases/crash/1.json
index 306bd90..f03ea34 100644
--- a/beat/backend/python/test/prefix/databases/crash/1.json
+++ b/beat/backend/python/test/prefix/databases/crash/1.json
@@ -1,5 +1,5 @@
 {
-  "root_folder": "/tmp/foo/bar",
+  "root_folder": "/tmp/beat_backend_python_test",
   "protocols": [
     {
       "name": "protocol",
diff --git a/beat/backend/python/test/prefix/databases/duplicate_key_error/1.json b/beat/backend/python/test/prefix/databases/duplicate_key_error/1.json
index f684a0f..a765c9d 100644
--- a/beat/backend/python/test/prefix/databases/duplicate_key_error/1.json
+++ b/beat/backend/python/test/prefix/databases/duplicate_key_error/1.json
@@ -1,5 +1,5 @@
 {
-    "root_folder": "/tmp/foo/bar",
+    "root_folder": "/tmp/beat_backend_python_test",
     "protocols": [
         {
             "name": "test_duplicate_key",
diff --git a/beat/backend/python/test/prefix/databases/integers_db/1.json b/beat/backend/python/test/prefix/databases/integers_db/1.json
index 402699b..cca34ab 100644
--- a/beat/backend/python/test/prefix/databases/integers_db/1.json
+++ b/beat/backend/python/test/prefix/databases/integers_db/1.json
@@ -1,5 +1,5 @@
 {
-    "root_folder": "/tmp/path/not/set",
+    "root_folder": "/tmp/beat_backend_python_test",
     "protocols": [
         {
             "name": "double",
diff --git a/beat/backend/python/test/prefix/databases/integers_db/2.json b/beat/backend/python/test/prefix/databases/integers_db/2.json
index c48d561..60376f4 100644
--- a/beat/backend/python/test/prefix/databases/integers_db/2.json
+++ b/beat/backend/python/test/prefix/databases/integers_db/2.json
@@ -1,7 +1,7 @@
 {
     "schema_version": 2,
 
-    "root_folder": "/tmp/path/not/set",
+    "root_folder": "/tmp/beat_backend_python_test",
     "protocols": [
         {
             "name": "double",
diff --git a/beat/backend/python/test/prefix/databases/integers_db_env/1.json b/beat/backend/python/test/prefix/databases/integers_db_env/1.json
index 71a4ad1..e557558 100644
--- a/beat/backend/python/test/prefix/databases/integers_db_env/1.json
+++ b/beat/backend/python/test/prefix/databases/integers_db_env/1.json
@@ -1,5 +1,5 @@
 {
-    "root_folder": "/tmp/path/not/set",
+    "root_folder": "/tmp/beat_backend_python_test",
     "environment": {
         "name": "Example databases",
         "version": "1.4.0"
diff --git a/beat/backend/python/test/prefix/databases/integers_db_env/2.json b/beat/backend/python/test/prefix/databases/integers_db_env/2.json
index 636da24..795bdda 100644
--- a/beat/backend/python/test/prefix/databases/integers_db_env/2.json
+++ b/beat/backend/python/test/prefix/databases/integers_db_env/2.json
@@ -4,7 +4,7 @@
         "name": "Example databases",
         "version": "1.4.0"
     },
-    "root_folder": "/tmp/path/not/set",
+    "root_folder": "/tmp/beat_backend_python_test",
     "protocols": [
         {
             "name": "double",
diff --git a/beat/backend/python/test/prefix/databases/python_keyword/1.json b/beat/backend/python/test/prefix/databases/python_keyword/1.json
index f724a10..792572d 100644
--- a/beat/backend/python/test/prefix/databases/python_keyword/1.json
+++ b/beat/backend/python/test/prefix/databases/python_keyword/1.json
@@ -1,5 +1,5 @@
 {
-    "root_folder": "/tmp/path/not/set",
+    "root_folder": "/tmp/beat_backend_python_test",
     "protocols": [
         {
             "name": "keyword",
diff --git a/beat/backend/python/test/prefix/databases/syntax_error/1.json b/beat/backend/python/test/prefix/databases/syntax_error/1.json
index 4d8d097..78fb6ba 100644
--- a/beat/backend/python/test/prefix/databases/syntax_error/1.json
+++ b/beat/backend/python/test/prefix/databases/syntax_error/1.json
@@ -1,5 +1,5 @@
 {
-  "root_folder": "/tmp/foo/bar",
+  "root_folder": "/tmp/beat_backend_python_test",
   "protocols": [
     {
       "name": "protocol",
diff --git a/beat/backend/python/test/prefix/databases/with_parameters/1.json b/beat/backend/python/test/prefix/databases/with_parameters/1.json
index c40f678..556b4ef 100644
--- a/beat/backend/python/test/prefix/databases/with_parameters/1.json
+++ b/beat/backend/python/test/prefix/databases/with_parameters/1.json
@@ -1,5 +1,5 @@
 {
-  "root_folder": "/tmp/foo/bar",
+  "root_folder": "/tmp/beat_backend_python_test",
   "protocols": [
     {
       "name": "test_with_parameters",
diff --git a/beat/backend/python/test/prefix/databases/with_parameters/2.json b/beat/backend/python/test/prefix/databases/with_parameters/2.json
index 9ca285c..f31b38f 100644
--- a/beat/backend/python/test/prefix/databases/with_parameters/2.json
+++ b/beat/backend/python/test/prefix/databases/with_parameters/2.json
@@ -1,5 +1,5 @@
 {
-    "root_folder": "/tmp/foo/bar",
+    "root_folder": "/tmp/beat_backend_python_test",
     "protocols": [
         {
             "name": "test_with_parameters",
-- 
GitLab