Skip to content

Commit

Permalink
Torii graphql comprehensive tests (#1078)
Browse files Browse the repository at this point in the history
* Torii graphql comprehensive tests

* fix test
  • Loading branch information
broody authored Oct 22, 2023
1 parent 5790166 commit 61b4f89
Show file tree
Hide file tree
Showing 9 changed files with 586 additions and 576 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 33 additions & 28 deletions crates/dojo-test-utils/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,40 @@ fn main() {
use scarb::ops;
use scarb_ui::Verbosity;

let target_path =
Utf8PathBuf::from_path_buf("../../examples/spawn-and-move/target".into()).unwrap();
if target_path.exists() {
return;
let project_paths =
vec!["../../examples/spawn-and-move", "../torii/graphql/src/tests/types-test"];

project_paths.iter().for_each(|path| compile(path));

fn compile(path: &str) {
let target_path = Utf8PathBuf::from_path_buf(format!("{}/target", path).into()).unwrap();
if target_path.exists() {
return;
}

let mut compilers = CompilerRepository::empty();
compilers.add(Box::new(DojoCompiler)).unwrap();

let cairo_plugins = CairoPluginRepository::default();

let cache_dir = assert_fs::TempDir::new().unwrap();
let config_dir = assert_fs::TempDir::new().unwrap();

let path = Utf8PathBuf::from_path_buf(format!("{}/Scarb.toml", path).into()).unwrap();
let config = Config::builder(path.canonicalize_utf8().unwrap())
.global_cache_dir_override(Some(Utf8Path::from_path(cache_dir.path()).unwrap()))
.global_config_dir_override(Some(Utf8Path::from_path(config_dir.path()).unwrap()))
.ui_verbosity(Verbosity::Verbose)
.log_filter_directive(env::var_os("SCARB_LOG"))
.compilers(compilers)
.cairo_plugins(cairo_plugins.into())
.build()
.unwrap();

let ws = ops::read_workspace(config.manifest_path(), &config).unwrap();
let packages = ws.members().map(|p| p.id).collect();
ops::compile(packages, &ws).unwrap();
}

let mut compilers = CompilerRepository::empty();
compilers.add(Box::new(DojoCompiler)).unwrap();

let cairo_plugins = CairoPluginRepository::default();

let cache_dir = assert_fs::TempDir::new().unwrap();
let config_dir = assert_fs::TempDir::new().unwrap();

let path =
Utf8PathBuf::from_path_buf("../../examples/spawn-and-move/Scarb.toml".into()).unwrap();
let config = Config::builder(path.canonicalize_utf8().unwrap())
.global_cache_dir_override(Some(Utf8Path::from_path(cache_dir.path()).unwrap()))
.global_config_dir_override(Some(Utf8Path::from_path(config_dir.path()).unwrap()))
.ui_verbosity(Verbosity::Verbose)
.log_filter_directive(env::var_os("SCARB_LOG"))
.compilers(compilers)
.cairo_plugins(cairo_plugins.into())
.build()
.unwrap();

let ws = ops::read_workspace(config.manifest_path(), &config).unwrap();
let packages = ws.members().map(|p| p.id).collect();
ops::compile(packages, &ws).unwrap();
}

#[cfg(not(feature = "build-examples"))]
Expand Down
3 changes: 3 additions & 0 deletions crates/torii/graphql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ warp.workspace = true

[dev-dependencies]
camino.workspace = true
dojo-test-utils = { path = "../../dojo-test-utils" }
dojo-world = { path = "../../dojo-world" }
starknet-crypto.workspace = true
starknet.workspace = true
scarb.workspace = true
sozo = { path = "../../sozo" }
Loading

0 comments on commit 61b4f89

Please sign in to comment.