• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

geo-engine / geoengine / 5751943360

03 Aug 2023 02:19PM UTC coverage: 89.422% (+0.4%) from 88.974%
5751943360

push

github

web-flow
Merge pull request #840 from geo-engine/remove_in_memory

Remove in memory contexts and dbs

5338 of 5338 new or added lines in 37 files covered. (100.0%)

103772 of 116048 relevant lines covered (89.42%)

62390.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

36.67
/services/src/pro/util/openapi_examples.rs
1
use crate::pro::contexts::ProPostgresContext;
2
use crate::pro::users::UserAuth;
3
use crate::util::openapi_examples::RunnableExample;
4
use actix_web::dev::ServiceResponse;
5
use actix_web::test::TestRequest;
6
use std::future::Future;
7
use tokio_postgres::NoTls;
8
use utoipa::openapi::{OpenApi, RefOr};
9

10
/// Runs all example requests against the provided test server to check for bad documentation,
11
/// for example due to incompatible schema changes between the time of writing the request body
12
/// and now. It can also detect if the query parameters are not documented correctly or the
13
/// request path changed.
14
///
15
/// # Panics
16
///
17
/// panics if the creation of an anonymous session fails or the example contains a Ref which is not yet supported.
18
pub async fn can_run_pro_examples<F, Fut>(
1✔
19
    app_ctx: ProPostgresContext<NoTls>,
1✔
20
    api: OpenApi,
1✔
21
    send_test_request: F,
1✔
22
) where
1✔
23
    F: Fn(TestRequest, ProPostgresContext<NoTls>) -> Fut
1✔
24
        + Send
1✔
25
        + std::panic::UnwindSafe
1✔
26
        + 'static
1✔
27
        + Clone,
1✔
28
    Fut: Future<Output = ServiceResponse>,
1✔
29
{
1✔
30
    let components = api.components.expect("api has at least one component");
1✔
31

32
    for (uri, path_item) in api.paths.paths {
56✔
33
        for (http_method, operation) in path_item.operations {
118✔
34
            if let Some(request_body) = operation.request_body {
63✔
35
                let with_auth = operation.security.is_some();
15✔
36

37
                for content in request_body.content.into_values() {
15✔
38
                    if let Some(example) = content.example {
15✔
39
                        RunnableExample {
40
                            components: &components,
×
41
                            http_method: &http_method,
×
42
                            uri: uri.as_str(),
×
43
                            parameters: &operation.parameters,
×
44
                            body: example,
×
45
                            with_auth,
×
46
                            session_id: app_ctx.create_anonymous_session().await.unwrap().id,
×
47
                            ctx: app_ctx.clone(),
×
48
                            send_test_request: &send_test_request,
×
49
                        }
×
50
                        .check_for_bad_documentation()
×
51
                        .await;
×
52
                    } else {
53
                        for example in content.examples.into_values() {
15✔
54
                            match example {
×
55
                                RefOr::Ref(_reference) => {
×
56
                                    // This never happened during testing.
×
57
                                    // It is undocumented how the references would look like.
×
58
                                    panic!("checking pro examples with references is not yet implemented")
×
59
                                }
60
                                RefOr::T(concrete) => {
×
61
                                    if let Some(body) = concrete.value {
×
62
                                        RunnableExample {
63
                                            components: &components,
×
64
                                            http_method: &http_method,
×
65
                                            uri: uri.as_str(),
×
66
                                            parameters: &operation.parameters,
×
67
                                            body,
×
68
                                            with_auth,
×
69
                                            session_id: app_ctx
×
70
                                                .create_anonymous_session()
×
71
                                                .await
×
72
                                                .unwrap()
×
73
                                                .id,
×
74
                                            ctx: app_ctx.clone(),
×
75
                                            send_test_request: &send_test_request,
×
76
                                        }
×
77
                                        .check_for_bad_documentation()
×
78
                                        .await;
×
79
                                    } else {
×
80
                                        //skip external examples
×
81
                                    }
×
82
                                }
83
                            }
84
                        }
85
                    }
86
                }
87
            }
48✔
88
        }
89
    }
90
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc