li7y/tests/licensing.rs
Simon Bruder 76901b1ab8
All checks were successful
/ build (push) Successful in 3m14s
Add licensing information page
2024-08-14 23:42:13 +02:00

50 lines
1.6 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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 &lt;simon@sbruder.de&gt;<"));
assert!(body.contains(">RustCrypto Developers<"));
// license links (only partial, as I dont 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<"##));
}