From d9d83d12358657ac0034b8e3842c49fdf9243c9d Mon Sep 17 00:00:00 2001 From: R1kaB3rN <100738684+R1kaB3rN@users.noreply.github.com> Date: Mon, 11 Mar 2024 05:44:49 -0700 Subject: [PATCH] ulwgl_test: add test for cache when offline --- ULWGL/ulwgl_test.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/ULWGL/ulwgl_test.py b/ULWGL/ulwgl_test.py index 9b89fa784..63690ae1a 100644 --- a/ULWGL/ulwgl_test.py +++ b/ULWGL/ulwgl_test.py @@ -956,6 +956,30 @@ def test_cache_interrupt(self): "Expected Proton dir in compat to be cleaned", ) + def test_cache_offline(self): + """Test _get_from_cache when the user is offline. + + In this case, we just get the first Proton that appears since we cannot determine the latest + """ + result = None + # When user is offline, there are no files + files = [] + + result = ulwgl_dl_util._get_from_cache( + self.env, self.test_compat, self.test_cache, files, False + ) + + # Verify that the old Proton was assigned + # The test file should be there + self.assertTrue(result is self.env, "Expected the same reference") + self.assertTrue( + os.environ["PROTONPATH"], "Expected PROTONPATH env var to be set" + ) + self.assertTrue( + self.env["PROTONPATH"], + "Expected PROTONPATH to be updated in dict", + ) + def test_cache_old(self): """Test _get_from_cache when the cache is empty.