Skip to content

Commit

Permalink
Create the bucket from the test itself when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
joselsegura committed Oct 31, 2023
1 parent b5a9923 commit 7a0b948
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ services:
createbuckets:
profiles:
- test-exporter
- test-parquet-factory
image: minio/mc
depends_on:
minio:
Expand Down
12 changes: 12 additions & 0 deletions features/src/minio.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ def minio_client(context: Context):
context.minio_client = client


def create_bucket(context: Context):
"""Remove the bucket if exists and re-create again."""
bucket_name = context.S3_bucket_name
found = context.minio_client.bucket_exists(bucket_name)

if found:
clean_bucket(context)
context.minio_client.remove_bucket(bucket_name)

context.minio_client.make_bucket(bucket_name)


def bucket_check(context: Context):
"""Check bucket existence."""
bucket_name = context.S3_bucket_name
Expand Down
4 changes: 2 additions & 2 deletions features/steps/exporter_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from src.minio import (
bucket_check,
clean_bucket,
create_bucket,
get_object_name,
minio_client,
read_object_into_buffer,
Expand Down Expand Up @@ -111,8 +112,7 @@ def assert_s3_bucket_is_empty(context):
@given("The S3 bucket is empty")
def ensure_s3_bucket_is_empty(context):
"""Ensure that the bucket is empty."""
bucket_check(context)
clean_bucket(context)
create_bucket(context)


@then("The S3 bucket is empty")
Expand Down

0 comments on commit 7a0b948

Please sign in to comment.