38 lines
1.3 KiB
Plaintext
38 lines
1.3 KiB
Plaintext
## Todo 2 — news-core domain types
|
|
|
|
Command: `cargo test -p news-core`
|
|
|
|
```
|
|
$ cargo test -p news-core
|
|
Finished `test` profile [unoptimized + debuginfo] target(s) in 0.03s
|
|
Running unittests src/lib.rs (target/debug/deps/news_core-73165881e402db9b)
|
|
|
|
running 2 tests
|
|
test model::tests::opinion_item_serializes_kind_as_snake_case_discriminant ... ok
|
|
test model::tests::round_trip ... ok
|
|
|
|
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
|
|
|
|
Doc-tests news_core
|
|
|
|
running 0 tests
|
|
|
|
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
|
|
```
|
|
|
|
- `round_trip` covers all 5 types (`Source`, `RawItem`, `StoryCluster`,
|
|
`ScoreBreakdown`, `Feedback`): serialize with `serde_json::to_string`,
|
|
deserialize back, `assert_eq!(decoded, original)` via `pretty_assertions`.
|
|
- `opinion_item_serializes_kind_as_snake_case_discriminant` locks the wire
|
|
format: a `RawItem` with `kind: ItemKind::Opinion` serializes the
|
|
discriminant as the literal string `"opinion"`.
|
|
|
|
Also verified clean (not required by acceptance criteria but run as part of
|
|
the post-write review loop):
|
|
|
|
```
|
|
$ cargo fmt --all --check # exit 0
|
|
$ cargo clippy -p news-core --all-targets -- -D warnings # exit 0, no warnings
|
|
$ cargo build --workspace # exit 0, all 6 crates compile
|
|
```
|