about summary refs log tree commit diff
path: root/tests/mapping_methods.rs
blob: 8cd504392fb20f1e6176848a946030363aeacb1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use axum::http::StatusCode;
use http_body_util::BodyExt;
use serde_json::Value;

mod common;

/// Needs a live MariaDB connection (SQL_URI) and a valid token; skips
/// rather than fails when either is missing, same as groups.rs.
#[tokio::test]
async fn mapping_methods_lists_the_tools() {
    if !common::db_available() {
        eprintln!(
            "skipping mapping_methods_lists_the_tools: no usable database (check SQL_URI credentials)"
        );
        return;
    }
    let Some(token) = common::auth_token().await else {
        eprintln!("skipping mapping_methods_lists_the_tools: no token (see docs/gn-auth.md)");
        return;
    };

    let response = common::get_with_token("GET /mapping-methods", "/mapping-methods", &token).await;
    assert_eq!(response.status(), StatusCode::OK);
    let body = response.into_body().collect().await.unwrap().to_bytes();
    let methods: Vec<Value> = common::data(&body);

    // The MappingMethod table lists tools no group uses (PLINK, FastMap).
    let names: Vec<&str> = methods.iter().map(|m| m["name"].as_str().unwrap()).collect();
    assert_eq!(names, ["qtlreaper", "Rqtl", "HappyR", "PLINK", "FastMap"]);
    assert_eq!(methods[0]["id"], 1);
}