Skip to content
This repository has been archived by the owner on Sep 12, 2018. It is now read-only.

Could not search #437

Open
wants to merge 3 commits into
base: rust
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions tests/external_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.

extern crate time;

extern crate mentat;
extern crate mentat_db;

use mentat::{new_connection, conn};

use std::io::prelude::*;
use std::fs::File;


#[test]
fn can_import_sqlite() {
Expand Down Expand Up @@ -56,3 +65,31 @@ fn can_import_sqlite() {
assert_eq!(me.data, p.data);
}
}

#[test]
fn test_big() {
let mut sqlite = new_connection("").unwrap();
let mut conn = conn::Conn::connect(&mut sqlite).unwrap();

let mut schema_file = File::open("tests/music-schema.dtm").expect("Unable to open the file");
let mut schema_contents = String::new();
schema_file.read_to_string(&mut schema_contents).expect("Unable to read the file. TODO: Please download them at <URL>");
let schema_transaction = conn.transact(&mut sqlite, schema_contents.as_str()).unwrap();
assert_eq!(schema_transaction.tx_id, 0x10000000 + 1);

// If you pull down the full dataset, you can replace the path here with
// tests/music-data.dtm.
let mut data_file = File::open("tests/music-data-partial.dtm").expect("Unable to open the file");
let mut data_contents = String::new();
data_file.read_to_string(&mut data_contents).expect("Unable to read the file. TODO: Please download them at <URL>");
let data_transaction = conn.transact(&mut sqlite, data_contents.as_str()).unwrap();
assert_eq!(data_transaction.tx_id, 0x10000000 + 2);

let results = conn.q_once(&mut sqlite,
r#"[:find ?name
:where
[?p :artist/name ?name]]"#, None)
.expect("Query failed");
println!("{:?}", results);
assert_eq!(874, results.len());
}
Loading