mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-05-14 11:48:28 -04:00
86089e338f
# Description of Changes This enables smoketests to run against remote servers, such as maincloud / maincloud staging. I also added a `--spacetime-login` param, for servers that require a "proper" spacetime login (such as both servers above). Usage: ```bash python3 -m smoketests \ --remote-server https://maincloud.staging.spacetimedb.com \ --spacetime-login \ -x replication # for some reason this is required, even though I swear it should be disabled by not passing `--docker` ``` # API and ABI breaking changes None. CI only. # Expected complexity level and risk 1 # Testing - [x] Smoketests pass on this PR - [x] Smoketests pass when run against maincloud staging (using the instructions above) - [x] Manual review to check whether I've accidentally de-fanged any "test for negative case" tests --------- Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
54 lines
1.3 KiB
Python
54 lines
1.3 KiB
Python
from .. import Smoketest, requires_anonymous_login
|
|
import time
|
|
|
|
class NewUserFlow(Smoketest):
|
|
AUTOPUBLISH = False
|
|
MODULE_CODE = """
|
|
use spacetimedb::{log, ReducerContext, Table};
|
|
|
|
#[spacetimedb::table(name = person)]
|
|
pub struct Person {
|
|
name: String
|
|
}
|
|
|
|
#[spacetimedb::reducer]
|
|
pub fn add(ctx: &ReducerContext, name: String) {
|
|
ctx.db.person().insert(Person { name });
|
|
}
|
|
|
|
#[spacetimedb::reducer]
|
|
pub fn say_hello(ctx: &ReducerContext) {
|
|
for person in ctx.db.person().iter() {
|
|
log::info!("Hello, {}!", person.name);
|
|
}
|
|
log::info!("Hello, World!");
|
|
}
|
|
"""
|
|
|
|
@requires_anonymous_login
|
|
def test_new_user_flow(self):
|
|
"""Test the entirety of the new user flow."""
|
|
|
|
## Publish your module
|
|
self.new_identity()
|
|
|
|
self.publish_module()
|
|
|
|
# Calling our database
|
|
self.call("say_hello")
|
|
self.assertIn("Hello, World!", self.logs(2))
|
|
|
|
## Calling functions with arguments
|
|
self.call("add", "Tyler")
|
|
self.call("say_hello")
|
|
self.assertEqual(self.logs(5).count("Hello, World!"), 2)
|
|
self.assertEqual(self.logs(5).count("Hello, Tyler!"), 1)
|
|
|
|
out = self.spacetime("sql", self.database_identity, "SELECT * FROM person")
|
|
# The spaces after the name are important
|
|
self.assertMultiLineEqual(out, """\
|
|
name
|
|
---------
|
|
"Tyler"
|
|
""")
|