Skip to content

Commit 23a32ee

Browse files
committed
test (#1)
* test * Fixed CI * Fixed tests * Fixed formatting * Fixed test error by removing chrono default features * Rename smoketests CI thing * Hopefully fix the testing issue * Fix typos * Fixed install git-hooks * Fixed formatting * Fixed compile error * fixed testing issues
1 parent 3cdf3fa commit 23a32ee

28 files changed

+30
-17
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ name: CI
88

99
jobs:
1010
docker_smoketests:
11+
name: Smoketests
1112
runs-on: ubuntu-latest
1213
steps:
1314
- uses: actions/checkout@v3
@@ -63,7 +64,7 @@ jobs:
6364
- run: echo ::add-matcher::.github/workflows/rust_matcher.json
6465

6566
- name: Build rust-wasm-test
66-
run: cargo run -p spacetimedb-cli -- build crates/modules/rust-wasm-test
67+
run: cargo run -p spacetimedb-cli -- build modules/rust-wasm-test
6768

6869
- name: Run bindgen tests
6970
run: cargo test -p spacetimedb-cli

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ members = [
1818
"crates/sqltest",
1919
"modules/rust-wasm-test",
2020
"modules/benchmarks",
21-
"modules/spacetimedb_quickstart",
21+
"modules/spacetimedb-quickstart",
2222
]
2323
default-members = ["crates/cli"]
2424

crates/lib/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ anyhow = "1.0.68"
2828
spacetimedb-bindings-macro = { path = "../bindings-macro", version = "0.4.1" }
2929
spacetimedb-sats = { path = "../sats", version = "0.4.1" }
3030
serde_with = { version = "2.2.0", optional = true }
31-
chrono = { version = "0.4.23", optional = true }
31+
chrono = { version = "0.4.23", optional = true, default-features = false }
3232

3333
[dev-dependencies]
3434
rand = "0.8.5"

crates/standalone/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ impl StandaloneEnv {
7171
}
7272

7373
fn get_or_create_keys() -> anyhow::Result<(DecodingKey, EncodingKey)> {
74-
let public_key_path = get_key_path("SPACETIMEDB_JWT_PUB_KEY").unwrap_or(PathBuf::from("/etc/spacetimedb/id_ecdsa.pub"));
75-
let private_key_path = get_key_path("SPACETIMEDB_JWT_PRIV_KEY").unwrap_or(PathBuf::from("/etc/spacetimedb/id_ecdsa"));
74+
let public_key_path =
75+
get_key_path("SPACETIMEDB_JWT_PUB_KEY").unwrap_or(PathBuf::from("/etc/spacetimedb/id_ecdsa.pub"));
76+
let private_key_path =
77+
get_key_path("SPACETIMEDB_JWT_PRIV_KEY").unwrap_or(PathBuf::from("/etc/spacetimedb/id_ecdsa"));
7678

7779
let mut public_key_bytes = read_key(&public_key_path).ok();
7880
let mut private_key_bytes = read_key(&private_key_path).ok();

crates/testing/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use spacetimedb::stdb_path;
12
use std::env;
23
use std::path::Path;
34

@@ -9,6 +10,6 @@ pub fn set_key_env_vars() {
910
env::set_var(var, Path::new(env!("CARGO_MANIFEST_DIR")).join("../..").join(path));
1011
}
1112
};
12-
set_if_not_exist("SPACETIMEDB_JWT_PUB_KEY", "id_ecdsa.pub");
13-
set_if_not_exist("SPACETIMEDB_JWT_PRIV_KEY", "id_ecdsa");
13+
set_if_not_exist("SPACETIMEDB_JWT_PUB_KEY", stdb_path("id_ecdsa.pub"));
14+
set_if_not_exist("SPACETIMEDB_JWT_PRIV_KEY", stdb_path("id_ecdsa"));
1415
}

crates/testing/src/modules.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,35 @@ where
4949
func(runtime, &module);
5050
});
5151
}
52-
fn module_path(path: &str) -> PathBuf {
52+
53+
fn module_path(name: &str) -> PathBuf {
5354
let root = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
54-
root.join("../modules").join(path)
55+
root.join("../../modules").join(name)
5556
}
5657

57-
fn wasm_path(path: &str) -> PathBuf {
58-
module_path(path).join("target/wasm32-unknown-unknown/release/spacetime_module.wasm")
58+
fn wasm_path(name: &str) -> PathBuf {
59+
module_path(name).join(format!(
60+
"target/wasm32-unknown-unknown/release/{}_module.wasm",
61+
name.replace('-', "_")
62+
))
5963
}
6064

6165
fn read_module(path: &str) -> Vec<u8> {
66+
println!("{}", wasm_path(path).to_str().unwrap());
6267
std::fs::read(wasm_path(path)).unwrap()
6368
}
6469

6570
pub fn compile(path: &str) {
6671
let path = module_path(path);
6772
let output = Command::new("cargo")
6873
.current_dir(&path)
69-
.args(["build", "--target=wasm32-unknown-unknown", "--release"])
74+
.args([
75+
"build",
76+
"--target=wasm32-unknown-unknown",
77+
"--release",
78+
"--target-dir",
79+
path.join("target").to_str().unwrap(),
80+
])
7081
.output()
7182
.expect("Failed to execute process to compile a test depdendency");
7283

crates/testing/tests/standalone_integration_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use spacetimedb_testing::modules::{compile, with_module_async};
33

44
#[test]
55
fn test_calling_a_reducer() {
6-
compile("spacetimedb_quickstart");
7-
with_module_async("spacetimedb_quickstart", |module| async move {
6+
compile("spacetimedb-quickstart");
7+
with_module_async("spacetimedb-quickstart", |module| async move {
88
let json = r#"{"call": {"fn": "add", "args": ["Tyrion"]}}"#.to_string();
99
module.send(json).await.unwrap();
1010
let json = r#"{"call": {"fn": "say_hello", "args": []}}"#.to_string();

docker-compose-release.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ services:
1414
- ./crates/bindings:/usr/src/app/crates/bindings
1515
- ./crates/bindings-macro:/usr/src/app/crates/bindings-macro
1616
- ./crates/bindings-sys:/usr/src/app/crates/bindings-sys
17-
- ./crates/modules/rust-wasm-test:/usr/src/app/crates/modules/rust-wasm-test
1817
- ./crates/vm:/usr/src/app/crates/vm
1918
- /stdb
2019
ports:

docker-compose.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ services:
1616
- ./crates/bindings:/usr/src/app/crates/bindings
1717
- ./crates/bindings-macro:/usr/src/app/crates/bindings-macro
1818
- ./crates/bindings-sys:/usr/src/app/crates/bindings-sys
19-
- ./crates/modules/rust-wasm-test:/usr/src/app/crates/modules/rust-wasm-test
2019
- ./crates/vm:/usr/src/app/crates/vm
2120
- ./crates/client-api-messages:/usr/src/app/crates/client-api-messages
2221
- ./flamegraphs:/usr/src/app/flamegraphs
File renamed without changes.

0 commit comments

Comments
 (0)