Skip to content

Commit 774570a

Browse files
committed
Added more integration tests
1 parent 2bbec97 commit 774570a

2 files changed

Lines changed: 96 additions & 51 deletions

File tree

.github/workflows/ci.yml

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,38 @@ jobs:
8585
- name: Checkout code
8686
uses: actions/checkout@v4
8787

88+
- name: Install system dependencies
89+
run: |
90+
sudo apt-get update
91+
sudo apt-get install -y protobuf-compiler
92+
- name: Install Rust
93+
run: rustup toolchain install stable --component llvm-tools-preview
94+
- name: Install cargo-llvm-cov
95+
uses: taiki-e/install-action@cargo-llvm-cov
96+
- name: install nextest
97+
uses: taiki-e/install-action@nextest
98+
- name: Free up disk space
99+
run: |
100+
sudo rm -rf /usr/share/dotnet
101+
sudo rm -rf /opt/ghc
102+
sudo rm -rf /usr/local/share/boost
103+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
104+
df -h
105+
- uses: Swatinem/rust-cache@v2
106+
- name: Check code format
107+
run: cargo fmt --all -- --check
108+
- name: Check the package for errors
109+
run: cargo check --all
110+
- name: Execute rust tests
111+
run: cargo nextest run --all-features
112+
113+
- name: Install integration test dependencies
114+
run: |
115+
wget -qO- https://www.mongodb.org/static/pgp/server-7.0.asc | sudo gpg --dearmor -o /usr/share/keyrings/mongodb-server-7.0.gpg
116+
echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
117+
sudo apt-get update
118+
sudo apt-get install -y mongodb-mongosh redis-tools
119+
88120
- name: Seed MySQL data
89121
run: |
90122
mysql -h 127.0.0.1 -u skardi_user -pskardi_pass mydb <<'EOF'
@@ -151,13 +183,6 @@ jobs:
151183
(3, 'Monitor', 299.99);
152184
EOF
153185
154-
- name: Install mongosh
155-
run: |
156-
wget -qO- https://www.mongodb.org/static/pgp/server-7.0.asc | sudo gpg --dearmor -o /usr/share/keyrings/mongodb-server-7.0.gpg
157-
echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
158-
sudo apt-get update
159-
sudo apt-get install -y mongodb-mongosh
160-
161186
- name: Seed MongoDB data
162187
run: |
163188
mongosh "mongodb://root:rootpass@127.0.0.1:27017/?authSource=admin" <<'EOF'
@@ -204,11 +229,6 @@ jobs:
204229
})
205230
EOF
206231
207-
- name: Install system dependencies
208-
run: |
209-
sudo apt-get update
210-
sudo apt-get install -y protobuf-compiler redis-tools
211-
212232
- name: Seed Redis data
213233
run: |
214234
redis-cli -h 127.0.0.1 <<'EOF'
@@ -218,25 +238,6 @@ jobs:
218238
HSET mydb:products:PROD004 name "Mouse" category "Electronics" price "29.99" in_stock "true"
219239
HSET mydb:products:PROD005 name "Desk Chair" category "Furniture" price "199.99" in_stock "true"
220240
EOF
221-
- name: Install Rust
222-
run: rustup toolchain install stable --component llvm-tools-preview
223-
- name: Install cargo-llvm-cov
224-
uses: taiki-e/install-action@cargo-llvm-cov
225-
- name: install nextest
226-
uses: taiki-e/install-action@nextest
227-
- name: Free up disk space
228-
run: |
229-
sudo rm -rf /usr/share/dotnet
230-
sudo rm -rf /opt/ghc
231-
sudo rm -rf /usr/local/share/boost
232-
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
233-
df -h
234-
- uses: Swatinem/rust-cache@v2
235-
- name: Check code format
236-
run: cargo fmt --all -- --check
237-
- name: Check the package for errors
238-
run: cargo check --all
239-
- name: Execute rust tests
240-
run: cargo nextest run --all-features
241+
241242
- name: Execute Integration tests
242243
run: cargo nextest run --all-features -- --ignored

crates/sources/src/providers/mongo.rs

Lines changed: 63 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,8 +1648,12 @@ mod tests {
16481648
.await
16491649
.unwrap();
16501650

1651-
let before = query_all(&ctx, "SELECT product_id FROM products").await;
1652-
let before_count = total_rows(&before);
1651+
let before = query_all(
1652+
&ctx,
1653+
"SELECT product_id FROM products WHERE product_id = 'PROD_DEL'",
1654+
)
1655+
.await;
1656+
assert_eq!(total_rows(&before), 1);
16531657

16541658
ctx.sql("DELETE FROM products WHERE product_id = 'PROD_DEL'")
16551659
.await
@@ -1658,8 +1662,12 @@ mod tests {
16581662
.await
16591663
.expect("execute delete");
16601664

1661-
let after = query_all(&ctx, "SELECT product_id FROM products").await;
1662-
assert_eq!(total_rows(&after), before_count - 1);
1665+
let after = query_all(
1666+
&ctx,
1667+
"SELECT product_id FROM products WHERE product_id = 'PROD_DEL'",
1668+
)
1669+
.await;
1670+
assert_eq!(total_rows(&after), 0);
16631671
}
16641672

16651673
#[tokio::test]
@@ -1668,8 +1676,13 @@ mod tests {
16681676
let mut ctx = SessionContext::new();
16691677
register_ci_collection(&mut ctx, "products", "product_id").await;
16701678

1671-
let before = query_all(&ctx, "SELECT product_id FROM products").await;
1672-
let before_count = total_rows(&before);
1679+
// Verify a known row exists before and survives a no-op delete
1680+
let before = query_all(
1681+
&ctx,
1682+
"SELECT product_id FROM products WHERE product_id = 'PROD001'",
1683+
)
1684+
.await;
1685+
assert_eq!(total_rows(&before), 1);
16731686

16741687
ctx.sql("DELETE FROM products WHERE product_id = 'NONEXISTENT'")
16751688
.await
@@ -1678,8 +1691,12 @@ mod tests {
16781691
.await
16791692
.expect("execute delete");
16801693

1681-
let after = query_all(&ctx, "SELECT product_id FROM products").await;
1682-
assert_eq!(total_rows(&after), before_count);
1694+
let after = query_all(
1695+
&ctx,
1696+
"SELECT product_id FROM products WHERE product_id = 'PROD001'",
1697+
)
1698+
.await;
1699+
assert_eq!(total_rows(&after), 1);
16831700
}
16841701

16851702
// ─── Update tests (integration) ─────────────────────────────────────
@@ -1718,8 +1735,19 @@ mod tests {
17181735
let mut ctx = SessionContext::new();
17191736
register_ci_collection(&mut ctx, "products", "product_id").await;
17201737

1721-
let before = query_all(&ctx, "SELECT product_id FROM products").await;
1722-
let before_count = total_rows(&before);
1738+
// Verify a known row is unchanged after a no-op update
1739+
let before = query_all(
1740+
&ctx,
1741+
"SELECT price FROM products WHERE product_id = 'PROD002'",
1742+
)
1743+
.await;
1744+
assert_eq!(total_rows(&before), 1);
1745+
let price_before = before[0]
1746+
.column(0)
1747+
.as_any()
1748+
.downcast_ref::<Float64Array>()
1749+
.unwrap()
1750+
.value(0);
17231751

17241752
ctx.sql("UPDATE products SET price = 0.0 WHERE product_id = 'NONEXISTENT'")
17251753
.await
@@ -1728,8 +1756,19 @@ mod tests {
17281756
.await
17291757
.expect("execute update");
17301758

1731-
let after = query_all(&ctx, "SELECT product_id FROM products").await;
1732-
assert_eq!(total_rows(&after), before_count);
1759+
let after = query_all(
1760+
&ctx,
1761+
"SELECT price FROM products WHERE product_id = 'PROD002'",
1762+
)
1763+
.await;
1764+
assert_eq!(total_rows(&after), 1);
1765+
let price_after = after[0]
1766+
.column(0)
1767+
.as_any()
1768+
.downcast_ref::<Float64Array>()
1769+
.unwrap()
1770+
.value(0);
1771+
assert!((price_before - price_after).abs() < 0.01);
17331772
}
17341773

17351774
// ─── Combined DML test (integration) ────────────────────────────────
@@ -1740,9 +1779,6 @@ mod tests {
17401779
let mut ctx = SessionContext::new();
17411780
register_ci_collection(&mut ctx, "products", "product_id").await;
17421781

1743-
let before = query_all(&ctx, "SELECT product_id FROM products").await;
1744-
let before_count = total_rows(&before);
1745-
17461782
// 1. Insert
17471783
ctx.sql(
17481784
"INSERT INTO products (product_id, name, category, price, in_stock)
@@ -1753,8 +1789,12 @@ mod tests {
17531789
.collect()
17541790
.await
17551791
.unwrap();
1756-
let after_insert = query_all(&ctx, "SELECT product_id FROM products").await;
1757-
assert_eq!(total_rows(&after_insert), before_count + 1);
1792+
let after_insert = query_all(
1793+
&ctx,
1794+
"SELECT product_id FROM products WHERE product_id = 'PROD_RT'",
1795+
)
1796+
.await;
1797+
assert_eq!(total_rows(&after_insert), 1);
17581798

17591799
// 2. Update
17601800
ctx.sql("UPDATE products SET price = 20.0, name = 'RoundTripUpdated' WHERE product_id = 'PROD_RT'")
@@ -1782,8 +1822,12 @@ mod tests {
17821822
.collect()
17831823
.await
17841824
.unwrap();
1785-
let after_delete = query_all(&ctx, "SELECT product_id FROM products").await;
1786-
assert_eq!(total_rows(&after_delete), before_count);
1825+
let after_delete = query_all(
1826+
&ctx,
1827+
"SELECT product_id FROM products WHERE product_id = 'PROD_RT'",
1828+
)
1829+
.await;
1830+
assert_eq!(total_rows(&after_delete), 0);
17871831
}
17881832

17891833
// ─── Category filter test (integration) ─────────────────────────────

0 commit comments

Comments
 (0)