You've already forked AstralRinth
forked from didirus/AstralRinth
more games information, games route (#756)
* more games information, games route * adds banner url
This commit is contained in:
@@ -6,6 +6,7 @@ use std::rc::Rc;
|
||||
|
||||
pub mod oauth;
|
||||
pub mod oauth_clients;
|
||||
pub mod tags;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ApiV3 {
|
||||
|
||||
26
tests/common/api_v3/tags.rs
Normal file
26
tests/common/api_v3/tags.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
use actix_web::{
|
||||
dev::ServiceResponse,
|
||||
test::{self, TestRequest},
|
||||
};
|
||||
use labrinth::routes::v3::tags::GameData;
|
||||
|
||||
use crate::common::database::ADMIN_USER_PAT;
|
||||
|
||||
use super::ApiV3;
|
||||
|
||||
impl ApiV3 {
|
||||
// TODO: fold this into v3 API of other v3 testing PR
|
||||
pub async fn get_games(&self) -> ServiceResponse {
|
||||
let req = TestRequest::get()
|
||||
.uri("/v3/games")
|
||||
.append_header(("Authorization", ADMIN_USER_PAT))
|
||||
.to_request();
|
||||
self.call(req).await
|
||||
}
|
||||
|
||||
pub async fn get_games_deserialized(&self) -> Vec<GameData> {
|
||||
let resp = self.get_games().await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
test::read_body_json(resp).await
|
||||
}
|
||||
}
|
||||
23
tests/games.rs
Normal file
23
tests/games.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
// TODO: fold this into loader_fields.rs or tags.rs of other v3 testing PR
|
||||
|
||||
use crate::common::environment::TestEnvironment;
|
||||
|
||||
mod common;
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn get_games() {
|
||||
let test_env = TestEnvironment::build(None).await;
|
||||
let api = &test_env.v3;
|
||||
|
||||
let games = api.get_games_deserialized().await;
|
||||
|
||||
// There should be 2 games in the dummy data
|
||||
assert_eq!(games.len(), 2);
|
||||
assert_eq!(games[0].name, "minecraft-java");
|
||||
assert_eq!(games[1].name, "minecraft-bedrock");
|
||||
|
||||
assert_eq!(games[0].slug, "minecraft-java");
|
||||
assert_eq!(games[1].slug, "minecraft-bedrock");
|
||||
|
||||
test_env.cleanup().await;
|
||||
}
|
||||
Reference in New Issue
Block a user