Skip to content

Commit

Permalink
feat md_test
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenbspence committed Jun 17, 2024
1 parent 87c1089 commit d5eba55
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: MotherDuck Integration Test

on: [push, pull_request]

jobs:
test-motherduck:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install duckdb # Install the duckdb package
- name: Run MotherDuck Test
env:
MOTHERDUCK_TOKEN: ${{ secrets.MOTHERDUCK_TOKEN }}
run: python ./tests/motherduck_test.py
26 changes: 26 additions & 0 deletions tests/motherduck_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os

import duckdb

# Load the MotherDuck token from environment variables
motherduck_token = os.getenv('MOTHERDUCK_TOKEN')
if not motherduck_token:
raise ValueError("MOTHERDUCK_TOKEN is not set in the environment variables.")

# Create a connection to MotherDuck
conn = duckdb.connect(database=':memory:', access_mode='read_write', config={"access_token": motherduck_token})

# Create a test table
conn.execute("CREATE TABLE test_table (id INTEGER, name VARCHAR)")

# Insert data into the table
conn.execute("INSERT INTO test_table VALUES (1, 'Alice'), (2, 'Bob')")

# Query the table
result = conn.execute("SELECT * FROM test_table").fetchall()

# Check the results
if result == [(1, 'Alice'), (2, 'Bob')]:
print("Test Passed: Data matches expected results")
else:
raise Exception("Test Failed: Data does not match expected results")

0 comments on commit d5eba55

Please sign in to comment.