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

Function prepare_mock_db

examples/rocket_okapi_example/service/tests/prepare.rs:5–50  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3
4#[cfg(feature = "mock")]
5pub fn prepare_mock_db() -> DatabaseConnection {
6 MockDatabase::new(DatabaseBackend::Postgres)
7 .append_query_results([
8 [post::Model {
9 id: 1,
10 title: "Title A".to_owned(),
11 text: "Text A".to_owned(),
12 }],
13 [post::Model {
14 id: 5,
15 title: "Title C".to_owned(),
16 text: "Text C".to_owned(),
17 }],
18 [post::Model {
19 id: 6,
20 title: "Title D".to_owned(),
21 text: "Text D".to_owned(),
22 }],
23 [post::Model {
24 id: 1,
25 title: "Title A".to_owned(),
26 text: "Text A".to_owned(),
27 }],
28 [post::Model {
29 id: 1,
30 title: "New Title A".to_owned(),
31 text: "New Text A".to_owned(),
32 }],
33 [post::Model {
34 id: 5,
35 title: "Title C".to_owned(),
36 text: "Text C".to_owned(),
37 }],
38 ])
39 .append_exec_results([
40 MockExecResult {
41 last_insert_id: 6,
42 rows_affected: 1,
43 },
44 MockExecResult {
45 last_insert_id: 6,
46 rows_affected: 5,
47 },
48 ])
49 .into_connection()
50}

Callers 1

mainFunction · 0.70

Calls 4

into_connectionMethod · 0.80
append_exec_resultsMethod · 0.80
append_query_resultsMethod · 0.80
newFunction · 0.50

Tested by

no test coverage detected