From 206da0232867c8f3b0574649012c8d4337640e4b Mon Sep 17 00:00:00 2001
From: Oliver Walters <oliver.henry.walters@gmail.com>
Date: Mon, 16 May 2022 00:21:05 +1000
Subject: [PATCH] Skip some git hash checks if running tests under docker

---
 InvenTree/part/test_part.py | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/InvenTree/part/test_part.py b/InvenTree/part/test_part.py
index 5932c36757..2241b68c0d 100644
--- a/InvenTree/part/test_part.py
+++ b/InvenTree/part/test_part.py
@@ -5,6 +5,7 @@
 from __future__ import unicode_literals
 from allauth.account.models import EmailAddress
 
+from django.conf import settings
 from django.contrib.auth import get_user_model
 
 from django.test import TestCase
@@ -67,11 +68,21 @@ class TemplateTagTest(TestCase):
 
     def test_hash(self):
         result_hash = inventree_extras.inventree_commit_hash()
-        self.assertGreater(len(result_hash), 5)
+        if settings.DOCKER:
+            # Testing inside docker environment *may* return an empty git commit hash
+            # In such a case, skip this check
+            pass
+        else:
+            self.assertGreater(len(result_hash), 5)
 
     def test_date(self):
         d = inventree_extras.inventree_commit_date()
-        self.assertEqual(len(d.split('-')), 3)
+        if settings.DOCKER:
+            # Testing inside docker environment *may* return an empty git commit hash
+            # In such a case, skip this check
+            pass
+        else:
+            self.assertEqual(len(d.split('-')), 3)
 
     def test_github(self):
         self.assertIn('github.com', inventree_extras.inventree_github_url())