tests(trello): add tests for 'trello member get'
This commit is contained in:
parent
d3ba869fe8
commit
b63500fc75
5 changed files with 2490 additions and 2 deletions
2366
src/tests/responses/trello-member-get.json
Normal file
2366
src/tests/responses/trello-member-get.json
Normal file
File diff suppressed because it is too large
Load diff
|
@ -27,8 +27,8 @@ pub(crate) mod member;
|
|||
pub(crate) mod model;
|
||||
pub(crate) mod stack;
|
||||
|
||||
// #[cfg(test)]
|
||||
// mod tests;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
pub(crate) fn url(path: impl Into<String>) -> String {
|
||||
let path = path.into();
|
||||
|
|
91
src/trello/tests/member/get.rs
Normal file
91
src/trello/tests/member/get.rs
Normal file
|
@ -0,0 +1,91 @@
|
|||
//
|
||||
use super::*;
|
||||
|
||||
#[rstest::fixture]
|
||||
fn ctx() -> FullCtx {
|
||||
let fs = given::a_filesystem();
|
||||
let trello_config = given::a_trello_config();
|
||||
|
||||
let mock_net = given::a_network();
|
||||
mock_net
|
||||
.on()
|
||||
.get("https://api.trello.com/1/members/me/boards")
|
||||
.headers(HashMap::from([(
|
||||
s!("authorization"),
|
||||
f!(
|
||||
"OAuth oauth_consumer_key=\"{}\", oauth_token=\"{}\"",
|
||||
trello_config.api_key,
|
||||
trello_config.api_secret
|
||||
),
|
||||
)]))
|
||||
.respond(StatusCode::OK)
|
||||
.header("content-type", "application/json")
|
||||
.body(include_str!(
|
||||
"../../../tests/responses/trello-member-get.json"
|
||||
))
|
||||
.expect("mock request");
|
||||
|
||||
FullCtx {
|
||||
fs: fs.as_real(),
|
||||
net: mock_net.into(),
|
||||
prt: given::a_printer(),
|
||||
cfg: AppConfig {
|
||||
trello: trello_config,
|
||||
nextcloud: given::a_nextcloud_config(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
#[rstest::rstest]
|
||||
#[tokio::test]
|
||||
async fn dump(ctx: FullCtx) {
|
||||
//given
|
||||
let prt = ctx.prt.clone();
|
||||
let prt = prt.as_test().unwrap();
|
||||
|
||||
//when
|
||||
Command::Trello(TrelloCommand::Member(TrelloMemberCommand::Get {
|
||||
dump: true,
|
||||
}))
|
||||
.execute(ctx)
|
||||
.await
|
||||
.expect("execute");
|
||||
|
||||
//then
|
||||
let output = prt.output();
|
||||
assert_eq!(
|
||||
output.trim(),
|
||||
include_str!("../../../tests/responses/trello-member-get.json")
|
||||
);
|
||||
}
|
||||
|
||||
#[rstest::rstest]
|
||||
#[tokio::test]
|
||||
async fn no_dump(ctx: FullCtx) {
|
||||
//given
|
||||
let prt = ctx.prt.clone();
|
||||
let prt = prt.as_test().unwrap();
|
||||
|
||||
//when
|
||||
Command::Trello(TrelloCommand::Member(TrelloMemberCommand::Get {
|
||||
dump: false,
|
||||
}))
|
||||
.execute(ctx)
|
||||
.await
|
||||
.expect("execute");
|
||||
|
||||
//then
|
||||
let output = prt.output();
|
||||
assert_eq!(
|
||||
output.trim(),
|
||||
[
|
||||
"5db72d5517a6135e166fd862:0 Business: Cossmass Infinities",
|
||||
"5ecbae5cbf50fc4fa0e541fd:3 Editing: Cossmass Infinities",
|
||||
"5eccb96b04b4dc5666c64b7c:4 Published: Cossmass Infinities",
|
||||
"62ce6644f1613e2eb5c23b35:Daily Notes 2022",
|
||||
"5e6cb04f4f9a8b071f151037:DevProjects",
|
||||
"5ddd02148100bc44f129a16e:Fulfilment: Cossmass Infinities"
|
||||
]
|
||||
.join("\n")
|
||||
);
|
||||
}
|
4
src/trello/tests/member/mod.rs
Normal file
4
src/trello/tests/member/mod.rs
Normal file
|
@ -0,0 +1,4 @@
|
|||
//
|
||||
use super::*;
|
||||
|
||||
mod get;
|
27
src/trello/tests/mod.rs
Normal file
27
src/trello/tests/mod.rs
Normal file
|
@ -0,0 +1,27 @@
|
|||
#![allow(dead_code)]
|
||||
#![allow(unused_imports)]
|
||||
//
|
||||
use std::collections::HashMap;
|
||||
|
||||
use kxio::{
|
||||
net::{MockNet, StatusCode},
|
||||
print::Printer,
|
||||
};
|
||||
use pretty_assertions::assert_eq as assert_peq;
|
||||
use serde_json::json;
|
||||
|
||||
use crate::{
|
||||
execute::Execute,
|
||||
f, s,
|
||||
tests::given,
|
||||
trello::{
|
||||
board::TrelloBoardCommand,
|
||||
card::TrelloCardCommand,
|
||||
member::TrelloMemberCommand,
|
||||
model::{TrelloBoardId, TrelloCardId},
|
||||
TrelloCommand, TrelloConfig,
|
||||
},
|
||||
AppConfig, Command, FullCtx,
|
||||
};
|
||||
|
||||
mod member;
|
Loading…
Reference in a new issue