50 lines
1.6 KiB
Rust
50 lines
1.6 KiB
Rust
|
// SPDX-FileCopyrightText: 2024 Simon Bruder <simon@sbruder.de>
|
|||
|
//
|
|||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|||
|
|
|||
|
use actix_web::{body::MessageBody, test};
|
|||
|
use sqlx::PgPool;
|
|||
|
|
|||
|
#[allow(dead_code)]
|
|||
|
mod common;
|
|||
|
|
|||
|
#[sqlx::test(fixtures("default"))]
|
|||
|
async fn is_linked(pool: PgPool) {
|
|||
|
let srv = test::init_service(li7y::app(&common::config(), &pool)).await;
|
|||
|
|
|||
|
let req = test::TestRequest::get().uri("/login").to_request();
|
|||
|
|
|||
|
let res = test::call_service(&srv, req).await;
|
|||
|
|
|||
|
assert!(res.status().is_success());
|
|||
|
|
|||
|
let body = String::from_utf8(res.into_body().try_into_bytes().unwrap().to_vec()).unwrap();
|
|||
|
|
|||
|
assert!(body.contains(r#"<a href="/licensing">"#));
|
|||
|
}
|
|||
|
|
|||
|
#[sqlx::test(fixtures("default"))]
|
|||
|
async fn contains_basic_information(pool: PgPool) {
|
|||
|
let srv = test::init_service(li7y::app(&common::config(), &pool)).await;
|
|||
|
|
|||
|
let req = test::TestRequest::get().uri("/licensing").to_request();
|
|||
|
|
|||
|
let res = test::call_service(&srv, req).await;
|
|||
|
|
|||
|
assert!(res.status().is_success());
|
|||
|
|
|||
|
let body = String::from_utf8(res.into_body().try_into_bytes().unwrap().to_vec()).unwrap();
|
|||
|
|
|||
|
// crate names
|
|||
|
assert!(body.contains(">actix-web<"));
|
|||
|
assert!(body.contains(">sqlx-postgres<"));
|
|||
|
|
|||
|
// author names (only me and entries without email address)
|
|||
|
assert!(body.contains(">Simon Bruder <simon@sbruder.de><"));
|
|||
|
assert!(body.contains(">RustCrypto Developers<"));
|
|||
|
|
|||
|
// license links (only partial, as I don’t want to check class names)
|
|||
|
assert!(body.contains(r##"href="#license-Apache-2.0">Apache-2.0<"##));
|
|||
|
assert!(body.contains(r##"href="#license-MIT">MIT<"##));
|
|||
|
}
|