style(tests): rustfmt wrap on hash_password call #56

Merged
nrupard merged 6 commits from fix/pms-124-fmt-wrap into main 2026-06-04 02:29:13 +02:00
Owner

Post-merge cargo fmt --all --check on main (kicked off by the PMS-124 merge in #55) failed on tests/common/mod.rs:110-111. rustfmt wants the assignment wrapped instead of the method chain. Pure formatting fix, no behavior change.

#PMS-124

Post-merge `cargo fmt --all --check` on `main` (kicked off by the PMS-124 merge in #55) failed on `tests/common/mod.rs:110-111`. rustfmt wants the assignment wrapped instead of the method chain. Pure formatting fix, no behavior change. #PMS-124
style(tests): rustfmt wrap on hash_password call
Some checks failed
Check / fmt + clippy + compile + tests (pull_request) Failing after 28s
e56e42a79e
Post-merge `cargo fmt --all --check` on main flagged the wrap style in `tests/common/mod.rs:110-111`. rustfmt prefers wrapping the assignment so the call fits on one line. Pure formatting; no behavior change.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

#PMS-124
style(tests): allow dead_code on per-binary-unused common items
Some checks failed
Check / fmt + clippy + compile + tests (pull_request) Failing after 3m29s
c4727dcc85
`cargo clippy --all-targets -- -D warnings` on the merged PMS-124 work failed in each of the four integration-test binaries with `error: field 'pool' is never read`. Each test file (`tests/auth.rs`, `tests/contacts.rs`, `tests/tenants.rs`, `tests/tickets.rs`) compiles its own copy of `tests/common/mod.rs`, so dead-code analysis fires per binary on any harness item the particular binary does not happen to use.

`TestApp.pool` is kept on the handle so future tests can assert post-mutation state directly without a second pool-arg pattern; today no test reads it. `DEFAULT_TENANT_ID` is the same story (used by `tenants`/`tickets`, not `auth`/`contacts`).

Tag both with `#[allow(dead_code)]` and a comment explaining the per-binary lint context, instead of dropping the fields and forcing every future test to rebuild the boilerplate.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

#PMS-124
fix(ci): point DATABASE_URL at the postgres service name, not localhost
Some checks failed
Check / fmt + clippy + compile + tests (pull_request) Failing after 54s
81487c8d08
`#[sqlx::test]` integration tests timed out at "failed to connect to setup test database: PoolTimedOut" because `DATABASE_URL` pointed at `localhost`. Under the Forgejo Actions runner the job container and its service containers share a bridge network and the services are reachable by their service name on the container-internal port; `localhost` resolves to the job container itself, where nothing is listening on 5432. The `ports: 5432:5432` mapping in the previous version was a host-port publish that did nothing for an in-container client.

Switch the host to `postgres` (the service name) and drop the unused `ports:` block. Also tighten the health-check loop (5s interval, 20 retries) so a slow Alpine boot does not race the first test.

#PMS-124

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
fix(tests): send custom_fields: {} on create ticket, surface error body
Some checks failed
Check / fmt + clippy + compile + tests (pull_request) Failing after 1m2s
2de1bd8dca
CI integration run hit "create ticket should 2xx, got 500 Internal Server Error" on the tickets lifecycle test. `CreateTicketRequest.custom_fields: serde_json::Value` defaults to `Value::Null`, which sqlx encodes as SQL NULL on the bind. The `tickets.custom_fields` column is `JSONB NOT NULL DEFAULT '{}'`, so the INSERT failed the NOT NULL constraint and the handler turned it into a 500.

Send `custom_fields: {}` explicitly from the test body so the bind writes an empty JSONB object. While here, capture the response text before the status check so the next failure mode shows the actual error body in the panic message instead of just the status code.

The host-side fix would be to default `CreateTicketRequest.custom_fields` to `serde_json::json!({})` (or wrap it in `Option`) in `src/modules/tickets/models.rs`. PMS-124's scope is just the test harness, so keep that change for a follow-up.

#PMS-124

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
test(common): init tracing subscriber so the real sqlx error surfaces
Some checks failed
Check / fmt + clippy + compile + tests (pull_request) Failing after 2m58s
fb96025c19
`tests/tickets.rs` keeps failing with `500 Database error: Database operation failed`. That generic message is hard-coded in `src/utils/error.rs`'s `From<sqlx::Error> for AppError` impl, which logs the real `sqlx::Error::Database(...)` payload via `tracing::error!` and then returns the generic body. With no tracing subscriber installed in the test process the payload disappears.

Install a `tracing_subscriber::fmt` subscriber with `with_test_writer()` so each test's stderr capture grabs the real payload; the panic dump on a failing test will then carry it. `try_init` because integration tests run concurrent inside one binary and the global subscriber can only be set once.

Pure diagnostic; doesn't change harness behavior or test assertions.

#PMS-124

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
fix(tickets): cast sla_targets DECIMAL columns to float8 for sqlx decode
All checks were successful
Check / fmt + clippy + compile + tests (pull_request) Successful in 1m3s
Build OCI container / Build and push mokosh-api image (push) Successful in 3m4s
Create release / Create release from merged PR (pull_request) Has been skipped
81a294c4fb
`TicketService::calculate_sla_dates` queried `sla_targets.first_response_hours` and `sla_targets.resolution_hours` as `(Option<f64>, Option<f64>)`, but the schema declares both columns as `DECIMAL(10, 2)`. sqlx refused to decode NUMERIC into `f64` and returned `ColumnDecode { Rust type Option<f64> is not compatible with SQL type NUMERIC }`, which got swallowed by the generic `Database operation failed` error message. End result: every ticket create against a tenant that had any default SLA policy seeded (i.e. every tenant created from migration 002) failed with a 500 once the post-INSERT SLA-calculation step ran.

Cast the two columns to `float8` in the SQL projection so the existing `Option<f64>` decode shape keeps working. No type or behavior change in the calling code, which already multiplies the hours by 60.0 in floating point.

Caught by the new `tests/tickets.rs` integration test wired up in PMS-124 #56.

#PMS-124

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
nrupard deleted branch fix/pms-124-fmt-wrap 2026-06-04 02:29:13 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-server!56
No description provided.