Skip to content

Case conversion tests#4450

Open
Shubham8287 wants to merge 23 commits intomasterfrom
shub/case-tests
Open

Case conversion tests#4450
Shubham8287 wants to merge 23 commits intomasterfrom
shub/case-tests

Conversation

@Shubham8287
Copy link
Contributor

Description of Changes

API and ABI breaking changes

Expected complexity level and risk

Testing

Shubham8287 and others added 16 commits February 23, 2026 18:00
Tests case conversion of names with digit boundaries against the
sdk-test-case-conversion-ts module:

- Table accessors: player_1(), person_2(), players_at_level_2()
- Fields with digits: player_1_id, current_level_2, status_3_field,
  age_value_1, person_2_id
- Enum variants: Player2Status::Active1, Player2Status::BannedUntil
- Nested structs: Person3Info with digit-boundary fields
- Reducers: create_player_1, add_person_2, ban_player_1 (explicit name)
- Views: Level2Players (canonical) → players_at_level_2 (accessor)
- SQL queries using canonical wire names

5 test cases:
  insert-player: insert + verify field names + enum
  insert-person: insert + verify nested struct fields
  ban-player: update via reducer with explicit name
  subscribe-view: subscribe to view with case-converted accessor
  subscribe-canonical-names: verify canonical names in SQL queries
All subscriptions now use .add_query() instead of raw SQL strings.

Tests:
  insert-player: query builder subscribe to player_1 table
  insert-person: query builder subscribe to player_1 + person_2
  ban-player: query builder subscribe + update via explicit-name reducer
  query-builder-filter: filter on digit-boundary column (current_level_2 == 5)
  query-builder-join: person_2 RIGHT SEMIJOIN player_1 ON player_ref = player_1_id
    Tests that digit-boundary column names work in join predicates
    and that joined results flow through case-converted accessors
- View renamed: Level2Players → Level2Person, accessor: person_at_level_2()
- View now returns Person2 rows (matching rightSemijoin semantics)
- player_name: Vec<String> → String
- IDs: u64 → u32 with autoInc
- BannedUntil: u64 → u32
- Regenerated all bindings
- Updated join test to listen for Person2 inserts (right side of join)
Rust equivalent of sdk-test-case-conversion-ts for testing case
conversion with digit-boundary names. Includes:

- Player2Status enum (Active1, BannedUntil(u32))
- Person3Info struct (AgeValue1, ScoreTotal)
- Player1Canonical table (Player1Id, player_name, currentLevel2, status3Field)
- Person2 table (Person2Id, FirstName, playerRef, personInfo)
- CreatePlayer1, AddPerson2 reducers
- banPlayer1 reducer (explicit name)
- Level2Person view (join via playerRef)
- Create TypeScript client test for sdk-test-case-conversion (Rust module)
- Add case_conversion_rust test module to test.rs
- Tests cover table subscriptions, reducer calls, query builder usage
- Verifies case-converted names work correctly from TypeScript → Rust
- Complements existing case_conversion_ts (Rust → TypeScript) tests
- Correct path from ../../typescript to ../typescript
- Change script from 'npm run test' to 'npm run start' to match test framework expectations
split_command_string() is a naive space-splitter that doesn't understand
shell operators like &&. npm was receiving '&&' as a package name argument.
Wrap the compound command in sh -c '...' so the shell interprets it.
- Rewrites case-conversion-test-client/src/index.ts to test the Rust
  module sdk-test-case-conversion from a TypeScript client
- Tests: insert-player, insert-person, ban-player, query-builder-filter,
  query-builder-join
- Verifies digit-boundary field names, nested structs, enum variants,
  explicit reducer names, and query builder filters/joins all work
  through case conversion from TypeScript
- Adds case_conversion_rust_ts_client test module in sdks/rust/tests/test.rs
@Shubham8287 Shubham8287 changed the title case tests Case conversion tests Feb 25, 2026
Shubham8287 and others added 3 commits February 25, 2026 19:47
- Add case-conversion-test-client to pnpm-workspace.yaml so
  'spacetimedb: workspace:*' resolves to the local SDK
- Restore subcommand dispatch in index.ts (was WIP/commented out)
- Fix dbNameOrPanic() to read from env var properly
- Add case_conversion_rust_ts_client test module in sdks/rust/tests/test.rs
  (uses pnpm install + pnpm build to compile the TS client)
- Add README with instructions to run locally
- Add .gitignore for node_modules/ and dist/
"clean": "rm -rf dist",
"build": "tsc",
"watch": "tsc -w",
"start": "node dist/index.js",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coolreader18 can you look at this test, help me how can I run this ?
pnpm start throws can not find modules pointing to some bindings.

Also, is it even the right place to put this test? Can you recommend a better way to setup it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants