Skip to content

Commit

Permalink
tests reproduce the issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Nintorac committed Dec 1, 2023
1 parent d7e16a4 commit 6209bdd
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions tests/functional/plugins/test_sqlite.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import os
import json
import pandas
import pytest
import sqlite3
from dbt.tests.util import (
check_relations_equal,
run_dbt,
)

model_sql = """
{{ config(materialized='incremental', database='satest') }}
select * from satest.tt1
"""


class TestSQLitePlugin:

@pytest.fixture(scope="class")
def sqlite_test_db(self):
path = '/tmp/satest.db'
os.unlink(path)
db = sqlite3.connect(path)
cursor = db.cursor()
cursor.execute("CREATE TABLE tt1 (id int, name text)")
cursor.execute("INSERT INTO tt1 VALUES (1, 'John Doe')")
cursor.execute("INSERT INTO tt1 VALUES (2, 'Jane Smith')")
cursor.execute("CREATE TABLE test_table2 (a int, b int, c int)")
cursor.execute("INSERT INTO test_table2 VALUES (1, 2, 3), (4, 5, 6)")
cursor.close()
db.commit()
db.close()

yield path

@pytest.fixture(scope="class")
def profiles_config_update(self, dbt_profile_target, sqlite_test_db):
return {
"test": {
"outputs": {
"dev": {
"type": "duckdb",
"path": dbt_profile_target.get("path", ":memory:"),
"attach": [
{'path': sqlite_test_db}
]
}
},
"target": "dev",
}
}

@pytest.fixture(scope="class")
def models(self, test_data_path):
return {
"read_write.sql": model_sql,

}

def test_sqlite_plugin(self, project):
results = run_dbt()
assert len(results) == 1

res = project.run_sql("SELECT COUNT(1) FROM satest.read_write", fetch="one")
assert res[0] == 2


0 comments on commit 6209bdd

Please sign in to comment.