MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / main

Function main

examples/rocket_example/service/tests/mock.rs:8–79  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6
7#[tokio::test]
8async fn main() {
9 let db = &prepare_mock_db();
10
11 {
12 let post = Query::find_post_by_id(db, 1).await.unwrap().unwrap();
13
14 assert_eq!(post.id, 1);
15 }
16
17 {
18 let post = Query::find_post_by_id(db, 5).await.unwrap().unwrap();
19
20 assert_eq!(post.id, 5);
21 }
22
23 {
24 let post = Mutation::create_post(
25 db,
26 post::Model {
27 id: 0,
28 title: "Title D".to_owned(),
29 text: "Text D".to_owned(),
30 },
31 )
32 .await
33 .unwrap();
34
35 assert_eq!(
36 post,
37 post::ActiveModel {
38 id: sea_orm::ActiveValue::Unchanged(6),
39 title: sea_orm::ActiveValue::Unchanged("Title D".to_owned()),
40 text: sea_orm::ActiveValue::Unchanged("Text D".to_owned())
41 }
42 );
43 }
44
45 {
46 let post = Mutation::update_post_by_id(
47 db,
48 1,
49 post::Model {
50 id: 1,
51 title: "New Title A".to_owned(),
52 text: "New Text A".to_owned(),
53 },
54 )
55 .await
56 .unwrap();
57
58 assert_eq!(
59 post,
60 post::Model {
61 id: 1,
62 title: "New Title A".to_owned(),
63 text: "New Text A".to_owned(),
64 }
65 );

Callers

nothing calls this directly

Calls 4

create_postFunction · 0.85
delete_postFunction · 0.85
unwrapMethod · 0.80
prepare_mock_dbFunction · 0.70

Tested by

no test coverage detected