Files
SpacetimeDB/crates/cli/tests/codegen.rs
Ingvar Stepanyan f5a13b6f26 Consistent filtering in Rust client + minor fixes (#1275)
* Extend codegen tests to Rust

* Replace cursive-chat module_bindings with symlink

* Implement consistent filtering rules for Rust

* Fixup

* Regenerate tests

* Fix non-deterministic import order

* cargo fmt

* Fix chat examples

* Change symlinks to files themselves

* Revert accidental change

This needs to wait for server-side API break to be implemented as well.
2024-05-28 13:02:25 +00:00

36 lines
1.1 KiB
Rust

use spacetimedb_cli::generate;
use spacetimedb_data_structures::map::HashMap;
use spacetimedb_testing::modules::{CompilationMode, CompiledModule};
use std::path::Path;
use std::sync::OnceLock;
fn compiled_module() -> &'static Path {
static COMPILED_MODULE: OnceLock<CompiledModule> = OnceLock::new();
COMPILED_MODULE
.get_or_init(|| CompiledModule::compile("rust-wasm-test", CompilationMode::Debug))
.path()
}
macro_rules! declare_tests {
($($name:ident => $lang:ident,)*) => {
$(
#[test]
fn $name() {
let outfiles: HashMap<_, _> = generate::generate(compiled_module(), generate::Language::$lang, "SpacetimeDB")
.unwrap()
.into_iter()
.collect();
insta::with_settings!({ sort_maps => true }, {
insta::assert_toml_snapshot!(outfiles);
});
}
)*
}
}
declare_tests! {
test_codegen_csharp => Csharp,
test_codegen_typescript => TypeScript,
test_codegen_rust => Rust,
}