fix crane

This commit is contained in:
Elijah McMorris 2024-08-07 10:02:43 -07:00
parent b402e3f503
commit 8063284c56
Signed by: NexVeridian
SSH key fingerprint: SHA256:bsA1SKZxuEcEVHAy3gY1HUeM5ykRJl0U0kQHQn0hMg8
5 changed files with 135 additions and 11 deletions

View file

@ -13,7 +13,7 @@ Install docker, vscode and the [Dev Containers Extension](https://marketplace.vi
Run code with `F5` or `cargo run`
Run tests with `cargo t`
Run tests with `nix flake check` or `cargo t`
## Docker Compose
`git clone`

4
Cargo.lock generated
View file

@ -478,9 +478,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
[[package]]
name = "cc"
version = "1.1.7"
version = "1.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc"
checksum = "504bdec147f2cc13c8b57ed9401fd8a147cc66b67ad5cb241394244f2c947549"
[[package]]
name = "cedar-policy"

121
flake.lock generated Normal file
View file

@ -0,0 +1,121 @@
{
"nodes": {
"advisory-db": {
"flake": false,
"locked": {
"lastModified": 1722017365,
"narHash": "sha256-9wYR5NZIgI+qzMDlJrUzevR31fvFQRgfjlYp50Xp3Ts=",
"owner": "rustsec",
"repo": "advisory-db",
"rev": "9d024c07ee8c18609b43436bc865abf46636e250",
"type": "github"
},
"original": {
"owner": "rustsec",
"repo": "advisory-db",
"type": "github"
}
},
"crane": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1722960479,
"narHash": "sha256-NhCkJJQhD5GUib8zN9JrmYGMwt4lCRp6ZVNzIiYCl0Y=",
"owner": "ipetkov",
"repo": "crane",
"rev": "4c6c77920b8d44cd6660c1621dea6b3fc4b4c4f4",
"type": "github"
},
"original": {
"owner": "ipetkov",
"repo": "crane",
"type": "github"
}
},
"fenix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"rust-analyzer-src": []
},
"locked": {
"lastModified": 1723012113,
"narHash": "sha256-AJGsmwDnheWMjZWUqgiGtBjbxMmvLvMp5WJhmTRhJ4w=",
"owner": "nix-community",
"repo": "fenix",
"rev": "3dab4ada5b0c5a22d56dbfd7e140c16f3df2e69a",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1722957468,
"narHash": "sha256-SQ0TCC4aklOhN/OzcztrKqDLY8SjpIZcyvTulzhDXs0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "2a13929e1f191b3690dd2f2db13098b04adb9043",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"advisory-db": "advisory-db",
"crane": "crane",
"fenix": "fenix",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View file

@ -31,7 +31,8 @@
inherit (pkgs) lib;
craneLib = crane.mkLib pkgs;
src = craneLib.cleanCargoSource ./.;
# src = craneLib.cleanCargoSource ./.;
src = ./.;
# Common arguments can be set here to avoid repeating them later
commonArgs = {

View file

@ -17,6 +17,12 @@ async fn inti_db() -> Result<Surreal<Db>, Error> {
Ok(db)
}
fn init_reader(file_format: &str, file_name: &str) -> Box<dyn BufRead> {
File_Format::new(file_format)
.reader(&format!("./tests/data/{}.{}", file_name, file_format))
.unwrap()
}
async fn entity_query(db: &Surreal<Db>) -> Result<Option<f32>, Error> {
let x: Option<f32> = db
.query(r#"
@ -36,9 +42,7 @@ async fn entity_query(db: &Surreal<Db>) -> Result<Option<f32>, Error> {
#[tokio::test]
async fn entity() {
let db = inti_db().await.unwrap();
let reader = File_Format::new("json")
.reader("tests/data/Entity.json")
.unwrap();
let reader = init_reader("json", "Entity");
for line in reader.lines() {
create_db_entity(&db, &line.unwrap()).await.unwrap();
@ -80,9 +84,7 @@ async fn property_query(db: &Surreal<Db>) -> Result<Option<f32>, Error> {
#[tokio::test]
async fn property() {
let db = inti_db().await.unwrap();
let reader = File_Format::new("json")
.reader("tests/data/Property.json")
.unwrap();
let reader = init_reader("json", "Property");
for line in reader.lines() {
create_db_entity(&db, &line.unwrap()).await.unwrap();
@ -93,7 +95,7 @@ async fn property() {
async fn property_threaded_insert(create_version: CreateVersion) -> Result<Surreal<Db>, Error> {
let db = inti_db().await?;
let reader = File_Format::new("json").reader("tests/data/Property.json")?;
let reader = init_reader("json", "Property");
create_db_entities_threaded(Some(db.clone()), reader, None, 1000, 100, create_version).await?;
Ok(db)