Skip to content

Commit e538ece

Browse files
committed
[bfops/cargo-test-all]: more server url
1 parent 6e1d0c9 commit e538ece

5 files changed

Lines changed: 30 additions & 18 deletions

File tree

modules/sdk-test-procedure-cpp/client/src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ fn on_sub_error(_ctx: &ErrorContext, err: Error) {
107107
/// Run the procedure tests
108108
fn run_tests(ctx: &DbConnection) {
109109
println!("\n=== Running Procedure Tests ===\n");
110+
let server_url: String = env::var("SPACETIMEDB_HOST").unwrap_or("http://localhost:3000".to_string());
110111

111112
// Test return_primitive
112113
println!("Testing return_primitive(10, 32)...");
@@ -232,7 +233,7 @@ fn run_tests(ctx: &DbConnection) {
232233

233234
// Test read_my_schema (HTTP)
234235
println!("Testing read_my_schema (HTTP)...");
235-
ctx.procedures.read_my_schema_then(|_, res| match res {
236+
ctx.procedures.read_my_schema_then(server_url, |_, res| match res {
236237
Ok(schema) => {
237238
if !schema.is_empty() {
238239
println!(" ✓ read_my_schema returned schema data ({} bytes)", schema.len());

modules/sdk-test-procedure-cpp/client/src/module_bindings/read_my_schema_procedure.rs

Lines changed: 12 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/sdk-test-procedure-cpp/src/lib.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,15 @@ SPACETIMEDB_PROCEDURE(Unit, insert_with_tx_rollback, ProcedureContext ctx) {
140140
#ifdef SPACETIMEDB_UNSTABLE_FEATURES
141141

142142
// Test HTTP GET request to the module's own schema endpoint
143-
SPACETIMEDB_PROCEDURE(std::string, read_my_schema, ProcedureContext ctx) {
143+
SPACETIMEDB_PROCEDURE(std::string, read_my_schema, ProcedureContext ctx, std::string server_url) {
144144
// Get the module identity (database address)
145145
Identity module_identity = ctx.database_identity();
146146
std::string identity_hex = module_identity.to_hex_string();
147147

148148
LOG_INFO("read_my_schema using identity: " + identity_hex);
149149

150150
// Make HTTP GET request to the schema endpoint (matches Rust)
151-
std::string url = "http://localhost:3000/v1/database/" + identity_hex + "/schema?version=9";
151+
std::string url = server_url + "/v1/database/" + identity_hex + "/schema?version=9";
152152
auto result = ctx.http.get(url);
153153

154154
if (!result.is_ok()) {

modules/sdk-test-procedure-cs/Lib.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ public static void WillPanic(ProcedureContext ctx)
6666
/// Test HTTP GET request to the module's own schema endpoint
6767
/// </summary>
6868
[SpacetimeDB.Procedure]
69-
public static string ReadMySchema(ProcedureContext ctx)
69+
public static string ReadMySchema(ProcedureContext ctx, string serverUrl)
7070
{
7171
var moduleIdentity = ProcedureContextBase.Identity;
72-
var result = ctx.Http.Get($"http://localhost:3000/v1/database/{moduleIdentity}/schema?version=9");
72+
var result = ctx.Http.Get($"{serverUrl}/v1/database/{moduleIdentity}/schema?version=9");
7373
return result.Match(
7474
response => response.Body.ToStringUtf8Lossy(),
7575
error => throw new Exception($"HTTP request failed: {error}")
@@ -243,4 +243,4 @@ public static void SortedUuidsInsert(ProcedureContext ctx)
243243
return 0;
244244
});
245245
}
246-
}
246+
}

modules/sdk-test-procedure-ts/src/index.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,17 @@ export const will_panic = spacetimedb.procedure(t.unit(), _ctx => {
9090
throw new Error('This procedure is expected to panic');
9191
});
9292

93-
export const read_my_schema = spacetimedb.procedure(t.string(), ctx => {
94-
const module_identity = ctx.databaseIdentity;
95-
const response = ctx.http.fetch(
96-
`http://localhost:3000/v1/database/${module_identity}/schema?version=9`
97-
);
98-
return response.text();
99-
});
93+
export const read_my_schema = spacetimedb.procedure(
94+
{ server_url: t.string() },
95+
t.string(),
96+
(ctx, { server_url }) => {
97+
const module_identity = ctx.databaseIdentity;
98+
const response = ctx.http.fetch(
99+
`${server_url}/v1/database/${module_identity}/schema?version=9`
100+
);
101+
return response.text();
102+
}
103+
);
100104

101105
export const invalid_request = spacetimedb.procedure(t.string(), ctx => {
102106
try {

0 commit comments

Comments
 (0)