Skip to content

Commit

Permalink
Add test to confirm testing can be disabled
Browse files Browse the repository at this point in the history
Signed-off-by: Bernhard Stadlbauer <[email protected]>
  • Loading branch information
bstadlbauer committed Jan 14, 2024
1 parent 565e593 commit 57e3012
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/flytekit/unit/core/test_local_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,25 @@ def check_evenness(n: int) -> bool:
assert n_cached_task_calls == 2


def test_cache_can_be_disabled(monkeypatch):
monkeypatch.setenv("FLYTE_LOCAL_CACHE_ENABLED", "false")

@task(cache=True, cache_version="v1")
def is_even(n: int) -> bool:
global n_cached_task_calls
n_cached_task_calls += 1
return n % 2 == 0

assert n_cached_task_calls == 0
# Run once and check that the counter is increased
assert is_even(n=1) is False
assert n_cached_task_calls == 1

# Run again and check that the counter is increased again i.e. no caching
assert is_even(n=1) is False
assert n_cached_task_calls == 2


def test_shared_tasks_in_two_separate_workflows():
@task(cache=True, cache_version="0.0.1")
def is_odd(n: int) -> bool:
Expand Down

0 comments on commit 57e3012

Please sign in to comment.