Skip to content

Commit

Permalink
Add tests for sqlite-vss extension
Browse files Browse the repository at this point in the history
  • Loading branch information
avinassh committed Feb 15, 2024
1 parent b2c3142 commit 13c1682
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
24 changes: 23 additions & 1 deletion .github/workflows/extensions-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,26 @@ jobs:
- name: test
run: |
cd ext/crr/rs/core
cargo test --features=loadable_extension
cargo test --features=loadable_extension
extensions-tests:
runs-on: ubuntu-latest
name: Extensions Tests

steps:
- uses: hecrj/setup-rust-action@v1
- name: Checkout repository
uses: actions/checkout@v3
- name: build libsql and ffi bindings
run: |
cargo xtask build-bundled
- name: download extensions
run: |
cd libsql-sqlite3/test/rust_suite
export VSS_VERSION="v0.1.2"
wget https://github.com/asg017/sqlite-vss/releases/download/$VSS_VERSION/sqlite-vss-$VSS_VERSION-loadable-linux-x86_64.tar.gz
tar -xvf sqlite-vss-$VSS_VERSION-loadable-linux-x86_64.tar.gz -C src
- name: test
run: |
cd libsql-sqlite3/test/rust_suite
cargo test
18 changes: 18 additions & 0 deletions libsql-sqlite3/test/rust_suite/src/extensions.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use libsql_sys::rusqlite::{Connection, params, LoadExtensionGuard};

#[test]
fn test_sqlite_vss() {
let conn = Connection::open_in_memory().unwrap();
unsafe {
let _guard = LoadExtensionGuard::new(&conn).unwrap();
conn.load_extension("src/vector0", None).unwrap();
conn.load_extension("src/vss0", None).unwrap();
}
conn.execute("CREATE VIRTUAL TABLE IF NOT EXISTS vss_demo USING vss0(a(2))", ())
.unwrap();
conn.execute("INSERT INTO vss_demo(rowid, a) VALUES (1, '[1.0, 2.0]'), (2, '[2.0, 2.0]'), (3, '[3.0, 2.0]')", ()).unwrap();
conn.execute(
"SELECT rowid, distance FROM vss_demo WHERE vss_search(?, ?) LIMIT 3",
params![1.0, 2.0],
).unwrap();
}
2 changes: 2 additions & 0 deletions libsql-sqlite3/test/rust_suite/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
mod alter_column;
mod random_rowid;
mod virtual_wal;
#[cfg(test)]
mod extensions;

#[cfg(all(test, feature = "udf"))]
mod user_defined_functions;
Expand Down

0 comments on commit 13c1682

Please sign in to comment.