CodeBench: Rust-tuki (--lang rust), golden example todo-rs, Dockerfile.cargo-test
- golden-examples/todo-rs/: Axum 0.8 + SQLx + SQLite, 10 testiä - prompts/code-rs.md: Rust-koodingenerointiprompt - Dockerfile.cargo-test: rust:1.87-slim testikontti - benchmark.mjs: --lang python|rust, kieliriippuvainen golden example, parseri tukee cargo test -tuloksia, src/ alihakemistot
This commit is contained in:
46
kipina-codebench/prompts/code-rs.md
Normal file
46
kipina-codebench/prompts/code-rs.md
Normal file
@@ -0,0 +1,46 @@
|
||||
You are a Rust backend developer. Generate an Axum web project with SQLx and SQLite.
|
||||
|
||||
Given the project requirements, JSON specification, and a REFERENCE IMPLEMENTATION, generate these files:
|
||||
|
||||
1. Cargo.toml — axum 0.8, tokio, serde/serde_json, sqlx (sqlite, runtime-tokio), tower-http
|
||||
2. src/models.rs — Structs with Serialize, Deserialize, FromRow derives
|
||||
3. src/handlers.rs — Async handler functions for each CRUD endpoint
|
||||
4. src/lib.rs — Public app() function returning Router, init_db() for table creation
|
||||
5. src/main.rs — Binary entry point, connect to SQLite, bind to port
|
||||
6. tests/api_test.rs — Integration tests using reqwest against in-memory SQLite
|
||||
|
||||
Do NOT generate any other files.
|
||||
|
||||
OUTPUT FORMAT — use these exact markers to separate files:
|
||||
|
||||
=== Cargo.toml ===
|
||||
<toml content>
|
||||
|
||||
=== src/models.rs ===
|
||||
<rust code>
|
||||
|
||||
=== src/handlers.rs ===
|
||||
<rust code>
|
||||
|
||||
=== src/lib.rs ===
|
||||
<rust code>
|
||||
|
||||
=== src/main.rs ===
|
||||
<rust code>
|
||||
|
||||
=== tests/api_test.rs ===
|
||||
<rust code>
|
||||
|
||||
DOCUMENTATION — every file starts with //! one-line module doc. Structs get /// one-line doc. Zensical: say what it IS, not what it does.
|
||||
|
||||
RULES:
|
||||
- Follow the REFERENCE IMPLEMENTATION patterns exactly
|
||||
- Use axum 0.8 API: Router, Json, Path, State, StatusCode
|
||||
- State is SqlitePool wrapped in axum::extract::State
|
||||
- Handlers return (StatusCode, Json<T>) or StatusCode
|
||||
- POST returns 201, DELETE returns 204, GET missing returns 404
|
||||
- sqlx::query_as for reads, sqlx::query for writes
|
||||
- Tests: each test spawns isolated server with in-memory SQLite on random port
|
||||
- Tests: unique descriptive data, NOT generic "test" strings
|
||||
- NO markdown fences inside file content — just raw code
|
||||
- Edition 2024 in Cargo.toml
|
||||
Reference in New Issue
Block a user