Skip to content

Commit

Permalink
chore: add schema_name to integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronsteers committed Sep 19, 2023
1 parent 5a133c9 commit 402a1a4
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,25 @@ def pytest_generate_tests(metafunc):
metafunc.parametrize("config", configs, indirect=True)


@pytest.fixture(scope="module")
def test_schema_name() -> str:
letters = string.ascii_lowercase
rand_string = "".join(random.choice(letters) for _ in range(6))
return f"test_schema_{rand_string}"


@pytest.fixture
def config(request) -> Dict[str, str]:
def config(request, test_schema_name: str) -> Dict[str, str]:
# create a file "myfile" in "mydir" in temp directory
if request.param == "local_file_config":
tmp_dir = tempfile.TemporaryDirectory()
test = os.path.join(str(tmp_dir.name), "test.duckdb")
yield {"destination_path": test}
yield {"destination_path": test, "schema:": test_schema_name}

elif request.param == "motherduck_config":
yield json.loads(Path(CONFIG_PATH).read_text())
config_dict = json.loads(Path(CONFIG_PATH).read_text())
config_dict["schema"] = test_schema_name
yield config_dict

else:
raise ValueError(f"Unknown config type: {request.param}")
Expand Down Expand Up @@ -165,6 +174,7 @@ def test_write(
airbyte_message2: AirbyteMessage,
airbyte_message3: AirbyteMessage,
test_table_name: str,
test_schema_name: str,
):
destination = DestinationDuckdb()
generator = destination.write(
Expand All @@ -179,7 +189,8 @@ def test_write(
con = duckdb.connect(database=config.get("destination_path"), read_only=False)
with con:
cursor = con.execute(
f"SELECT _airbyte_ab_id, _airbyte_emitted_at, _airbyte_data FROM _airbyte_raw_{test_table_name} ORDER BY _airbyte_data"
"SELECT _airbyte_ab_id, _airbyte_emitted_at, _airbyte_data "
f"FROM {test_schema_name}._airbyte_raw_{test_table_name} ORDER BY _airbyte_data"
)
result = cursor.fetchall()

Expand Down

0 comments on commit 402a1a4

Please sign in to comment.