Skip to content

Commit

Permalink
add unit test for gcs_storage refreshable creds
Browse files Browse the repository at this point in the history
  • Loading branch information
lindseynield committed Feb 24, 2025
1 parent a63a2b3 commit 399f275
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion icechunk-python/tests/test_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pytest

from icechunk import (
gcs_storage,
Repository,
S3Options,
S3StaticCredentials,
Expand Down Expand Up @@ -113,7 +114,7 @@ def __call__(self) -> S3StaticCredentials:
)


def test_refreshable_credentials_refresh(tmp_path: Path) -> None:
def test_s3_refreshable_credentials_refresh(tmp_path: Path) -> None:
path = tmp_path / "calls.txt"
creds_obj = ExpirableCredentials(path)

Expand All @@ -136,3 +137,25 @@ def test_refreshable_credentials_refresh(tmp_path: Path) -> None:
assert not Repository.exists(st)
assert not Repository.exists(st)
assert path.read_text() == "..."


def test_gcs_refreshable_credentials_refresh(tmp_path: Path) -> None:
path = tmp_path / "calls.txt"
creds_obj = ExpirableCredentials(path)

st = gcs_storage(
bucket="testbucket",
prefix="this-repo-does-not-exist",
get_credentials=creds_obj,
)

# credentials expire immediately so refresh function keeps getting called
assert not Repository.exists(st)
assert not Repository.exists(st)
assert not Repository.exists(st)
assert path.read_text() == "..."

# after three times credentials don't expire, so the file doesn't change
assert not Repository.exists(st)
assert not Repository.exists(st)
assert path.read_text() == "..."

0 comments on commit 399f275

Please sign in to comment.