Skip to content
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
200 changes: 200 additions & 0 deletions crates/smoketests/modules/Cargo.lock

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

31 changes: 29 additions & 2 deletions crates/smoketests/modules/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ members = [
# Views tests
"views-basic",
# "views-broken-namespace" - intentionally broken, uses runtime compilation
# "views-broken-return-type" - intentionally broken, uses runtime compilation
"views-broken-return-type",
"views-sql",
"views-auto-migrate",
"views-auto-migrate-updated",
Expand All @@ -35,6 +35,7 @@ members = [

# Security and permissions
"rls",
"rls-broken-private-table",
"rls-no-filter",
"rls-with-filter",
"permissions-private",
Expand All @@ -44,6 +45,31 @@ members = [
"call-reducer-procedure",
"call-reducer-procedure-identity-arg",
"call-empty",
"call-many",

# Auto-migration tests
"auto-migration-simple",
"auto-migration-incompatible",
"auto-migration-add-table-initial",
"auto-migration-add-table-updated",
"auto-migration-add-columns",
"auto-migration-add-columns-again",
"auto-migration-with-primary-key",
"auto-migration-without-primary-key",
"auto-migration-without-primary-key-v2",
"auto-migration-event-table-before",
"auto-migration-event-table-after",
"auto-migration-drop-event-table-before",
"auto-migration-drop-event-table-after",

# HTTP tests
"http-egress",
"http-routes",
"http-routes-example",
"http-routes-strict-root",
"http-routes-strict-non-root",
"http-routes-full-uri",
"http-routes-request-body",

# SQL format tests
"sql-format",
Expand Down Expand Up @@ -92,7 +118,8 @@ members = [
"namespaces",
"new-user-flow",
"module-nested-op",
# "fail-initial-publish-broken" - intentionally broken, uses runtime compilation
"noop",
"fail-initial-publish-broken",
"fail-initial-publish-fixed",

# Auto-increment tests (all 10 integer types in one module each)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "smoketest-module-auto-migration-add-columns-again"
version = "0.1.0"
edition = "2021"
publish = false

[lib]
crate-type = ["cdylib"]

[dependencies]
spacetimedb.workspace = true
log.workspace = true
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use spacetimedb::{log, ReducerContext, Table};

#[derive(Debug)]
#[spacetimedb::table(accessor = person)]
pub struct Person {
name: String,
age: u16,
#[default(19)]
mass: u16,
#[default(160)]
height: u32,
}

#[spacetimedb::reducer]
pub fn add_person(ctx: &ReducerContext, name: String) {
ctx.db.person().insert(Person {
name,
age: 70,
mass: 180,
height: 72,
});
}

#[spacetimedb::reducer]
pub fn print_persons(ctx: &ReducerContext, prefix: String) {
for person in ctx.db.person().iter() {
log::info!("{}: {:?}", prefix, person);
}
}
12 changes: 12 additions & 0 deletions crates/smoketests/modules/auto-migration-add-columns/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "smoketest-module-auto-migration-add-columns"
version = "0.1.0"
edition = "2021"
publish = false

[lib]
crate-type = ["cdylib"]

[dependencies]
spacetimedb.workspace = true
log.workspace = true
33 changes: 33 additions & 0 deletions crates/smoketests/modules/auto-migration-add-columns/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
use spacetimedb::{log, ReducerContext, Table};

#[derive(Debug)]
#[spacetimedb::table(accessor = person)]
pub struct Person {
#[index(btree)]
name: String,
#[default(0)]
age: u16,
#[default(19)]
mass: u16,
}

#[spacetimedb::reducer]
pub fn add_person(ctx: &ReducerContext, name: String) {
ctx.db.person().insert(Person {
name,
age: 70,
mass: 180,
});
}

#[spacetimedb::reducer]
pub fn print_persons(ctx: &ReducerContext, prefix: String) {
for person in ctx.db.person().iter() {
log::info!("{}: {:?}", prefix, person);
}
}

#[spacetimedb::reducer(client_disconnected)]
pub fn identity_disconnected(_ctx: &ReducerContext) {
log::info!("FIRST_UPDATE: client disconnected");
}
Loading
Loading