refactor: remove board_id and board_name from config file
Some checks failed
Test / build (map[name:stable]) (push) Successful in 2m47s
Test / build (map[name:nightly]) (push) Successful in 2m57s
Release Please / Release-plz (push) Failing after 23s

This commit is contained in:
Paul Campbell 2024-12-19 07:05:10 +00:00
parent 2df105bd65
commit 3249da92b0
12 changed files with 109 additions and 101 deletions

View file

@ -1,26 +1,21 @@
// //
use color_eyre::eyre::{OptionExt as _, Result}; use color_eyre::eyre::Result;
use crate::{f, p, trello::model::board::TrelloBoards as _, FullCtx}; use crate::{p, FullCtx};
pub(crate) async fn run(ctx: &FullCtx) -> Result<()> { pub(crate) async fn run(ctx: &FullCtx) -> Result<()> {
{ {
// test trello by getting a list of the boards for the user // test trello by getting a list of the boards for the user
p!(ctx.prt, ">> Testing Trello details..."); p!(ctx.prt, ">> Testing Trello details...");
let boards = ctx.trello_client().boards().await.result?; let boards = ctx.trello_client().boards().await.result?;
p!(ctx.prt, "<<< Trello Credentials: OKAY"); p!(ctx.prt, "<<< Trello Boards");
let board_name = &ctx.cfg.trello.board_name; for board in &boards {
p!(ctx.prt, ">> Trello Board: {board_name}"); p!(ctx.prt, "<<<< Board: {}", board.name);
let board = boards
.find_by_name(board_name)
.ok_or_eyre(f!("board not found: {board_name}"))?;
p!(ctx.prt, "<<< Trello Board: OKAY");
for list in &board.lists {
p!(ctx.prt, "<<<< List: {}", list.name);
} }
} }
{ {
// test nextcloud by getting a list of the boards for the user
p!(ctx.prt, ">> Testing Nextcloud details..."); p!(ctx.prt, ">> Testing Nextcloud details...");
let deck_client = ctx.deck_client(); let deck_client = ctx.deck_client();
let boards = deck_client.get_boards().await.result?; let boards = deck_client.get_boards().await.result?;
@ -28,19 +23,6 @@ pub(crate) async fn run(ctx: &FullCtx) -> Result<()> {
for board in &boards { for board in &boards {
p!(ctx.prt, "<<<< Board: {}", board.title); p!(ctx.prt, "<<<< Board: {}", board.title);
} }
p!(ctx.prt, "<<< Nextcloud Credentials: OKAY");
let board = boards
.iter()
.find(|b| b.id == ctx.cfg.nextcloud.board_id)
.ok_or_eyre("board not found")?;
p!(ctx.prt, "<<< Nextcloud Board: {}", board.title);
let stacks = deck_client
.get_stacks(ctx.cfg.nextcloud.board_id)
.await
.result?;
for stack in stacks {
p!(ctx.prt, "<<<< Stack: {}", stack.title);
}
} }
Ok(()) Ok(())

View file

@ -7,7 +7,7 @@ use crate::{
nextcloud::{ nextcloud::{
card::NextcloudCardCommand, card::NextcloudCardCommand,
deck::NextcloudDeckCommand, deck::NextcloudDeckCommand,
model::{NextcloudBoardId, NextcloudHostname, NextcloudPassword, NextcloudUsername}, model::{NextcloudHostname, NextcloudPassword, NextcloudUsername},
stack::NextcloudStackCommand, stack::NextcloudStackCommand,
}, },
FullCtx, FullCtx,
@ -57,5 +57,4 @@ pub struct NextcloudConfig {
pub(crate) hostname: NextcloudHostname, pub(crate) hostname: NextcloudHostname,
pub(crate) username: NextcloudUsername, pub(crate) username: NextcloudUsername,
pub(crate) password: NextcloudPassword, pub(crate) password: NextcloudPassword,
pub(crate) board_id: NextcloudBoardId,
} }

View file

@ -7,6 +7,11 @@ use crate::Command;
// //
use super::*; use super::*;
#[rstest::fixture]
fn board_id() -> NextcloudBoardId {
NextcloudBoardId::new(1)
}
#[rstest::fixture] #[rstest::fixture]
fn ctx() -> FullCtx { fn ctx() -> FullCtx {
let fs = given::a_filesystem(); let fs = given::a_filesystem();
@ -14,7 +19,7 @@ fn ctx() -> FullCtx {
let nextcloud_config = given::a_nextcloud_config(); let nextcloud_config = given::a_nextcloud_config();
let hostname = &nextcloud_config.hostname; let hostname = &nextcloud_config.hostname;
let board_id = nextcloud_config.board_id; let board_id = board_id();
let mock_net = given::a_network(); let mock_net = given::a_network();
mock_net mock_net
@ -33,11 +38,10 @@ fn ctx() -> FullCtx {
#[rstest::rstest] #[rstest::rstest]
#[test_log::test(tokio::test)] #[test_log::test(tokio::test)]
async fn dump(ctx: FullCtx) { async fn dump(ctx: FullCtx, board_id: NextcloudBoardId) {
//given //given
let prt = ctx.prt.clone(); let prt = ctx.prt.clone();
let prt = prt.as_test().unwrap(); let prt = prt.as_test().unwrap();
let board_id = ctx.cfg.nextcloud.board_id;
//when //when
Command::Nextcloud(NextcloudCommand::Board(NextcloudBoardCommand::Get { Command::Nextcloud(NextcloudCommand::Board(NextcloudBoardCommand::Get {
@ -58,7 +62,7 @@ async fn dump(ctx: FullCtx) {
#[rstest::rstest] #[rstest::rstest]
#[test_log::test(tokio::test)] #[test_log::test(tokio::test)]
async fn no_dump(ctx: FullCtx) { async fn no_dump(ctx: FullCtx, board_id: NextcloudBoardId) {
//given //given
let prt = ctx.prt.clone(); let prt = ctx.prt.clone();
let prt = prt.as_test().unwrap(); let prt = prt.as_test().unwrap();
@ -66,7 +70,7 @@ async fn no_dump(ctx: FullCtx) {
//when //when
Command::Nextcloud(NextcloudCommand::Board(NextcloudBoardCommand::Get { Command::Nextcloud(NextcloudCommand::Board(NextcloudBoardCommand::Get {
dump: false, dump: false,
board_id: ctx.cfg.nextcloud.board_id.into(), board_id: board_id.into(),
})) }))
.execute(&ctx) .execute(&ctx)
.await .await

View file

@ -8,6 +8,11 @@ use std::path::PathBuf;
// //
use super::*; use super::*;
#[rstest::fixture]
fn board_id() -> NextcloudBoardId {
NextcloudBoardId::new(2)
}
#[rstest::fixture] #[rstest::fixture]
fn stack_id() -> NextcloudStackId { fn stack_id() -> NextcloudStackId {
NextcloudStackId::new(1) NextcloudStackId::new(1)
@ -29,7 +34,7 @@ fn ctx_path() -> (FullCtx, PathBuf, TempFileSystem) {
let nextcloud_config = given::a_nextcloud_config(); let nextcloud_config = given::a_nextcloud_config();
let hostname = &nextcloud_config.hostname; let hostname = &nextcloud_config.hostname;
let board_id = &nextcloud_config.board_id; let board_id = board_id();
let stack_id = stack_id(); let stack_id = stack_id();
let card_id = card_id(); let card_id = card_id();
@ -91,6 +96,7 @@ fn ctx_path() -> (FullCtx, PathBuf, TempFileSystem) {
#[test_log::test(tokio::test)] #[test_log::test(tokio::test)]
async fn dump( async fn dump(
ctx_path: (FullCtx, PathBuf, TempFileSystem), ctx_path: (FullCtx, PathBuf, TempFileSystem),
board_id: NextcloudBoardId,
stack_id: NextcloudStackId, stack_id: NextcloudStackId,
card_id: NextcloudCardId, card_id: NextcloudCardId,
) { ) {
@ -103,7 +109,7 @@ async fn dump(
Command::Nextcloud(NextcloudCommand::Card( Command::Nextcloud(NextcloudCommand::Card(
NextcloudCardCommand::AddAttachment { NextcloudCardCommand::AddAttachment {
dump: true, dump: true,
board_id: ctx.cfg.nextcloud.board_id.into(), board_id: board_id.into(),
stack_id: stack_id.into(), stack_id: stack_id.into(),
card_id: card_id.into(), card_id: card_id.into(),
file: path, file: path,
@ -125,6 +131,7 @@ async fn dump(
#[test_log::test(tokio::test)] #[test_log::test(tokio::test)]
async fn no_dump( async fn no_dump(
ctx_path: (FullCtx, PathBuf, TempFileSystem), ctx_path: (FullCtx, PathBuf, TempFileSystem),
board_id: NextcloudBoardId,
stack_id: NextcloudStackId, stack_id: NextcloudStackId,
card_id: NextcloudCardId, card_id: NextcloudCardId,
) { ) {
@ -137,7 +144,7 @@ async fn no_dump(
Command::Nextcloud(NextcloudCommand::Card( Command::Nextcloud(NextcloudCommand::Card(
NextcloudCardCommand::AddAttachment { NextcloudCardCommand::AddAttachment {
dump: false, dump: false,
board_id: ctx.cfg.nextcloud.board_id.into(), board_id: board_id.into(),
stack_id: stack_id.into(), stack_id: stack_id.into(),
card_id: card_id.into(), card_id: card_id.into(),
file: path, file: path,

View file

@ -1,5 +1,10 @@
use super::*; use super::*;
#[rstest::fixture]
fn board_id() -> NextcloudBoardId {
NextcloudBoardId::new(1)
}
#[rstest::fixture] #[rstest::fixture]
fn stack_id() -> NextcloudStackId { fn stack_id() -> NextcloudStackId {
NextcloudStackId::new(1) NextcloudStackId::new(1)
@ -19,14 +24,16 @@ fn label_id() -> NextcloudLabelId {
fn ctx() -> FullCtx { fn ctx() -> FullCtx {
let fs = given::a_filesystem(); let fs = given::a_filesystem();
let nextcloud_config = given::a_nextcloud_config(); let nextcloud_config = given::a_nextcloud_config();
let hostname = &nextcloud_config.hostname;
let board_id = board_id();
let stack_id = stack_id();
let card_id = card_id();
let mock_net = given::a_network(); let mock_net = given::a_network();
mock_net mock_net
.on() .on()
.put(crate::f!( .put(crate::f!(
"{}/index.php/apps/deck/api/v1.0/boards/{}/stacks/1/cards/1/assignLabel", "{hostname}/index.php/apps/deck/api/v1.0/boards/{board_id}/stacks/{stack_id}/cards/{card_id}/assignLabel",
nextcloud_config.hostname,
nextcloud_config.board_id
)) ))
.body(json!({ "labelId": 1 }).to_string()) .body(json!({ "labelId": 1 }).to_string())
.respond(StatusCode::OK) .respond(StatusCode::OK)
@ -48,6 +55,7 @@ fn ctx() -> FullCtx {
#[test_log::test(tokio::test)] #[test_log::test(tokio::test)]
async fn dump( async fn dump(
ctx: FullCtx, ctx: FullCtx,
board_id: NextcloudBoardId,
stack_id: NextcloudStackId, stack_id: NextcloudStackId,
card_id: NextcloudCardId, card_id: NextcloudCardId,
label_id: NextcloudLabelId, label_id: NextcloudLabelId,
@ -59,7 +67,7 @@ async fn dump(
//when //when
Command::Nextcloud(NextcloudCommand::Card(NextcloudCardCommand::AddLabel { Command::Nextcloud(NextcloudCommand::Card(NextcloudCardCommand::AddLabel {
dump: true, dump: true,
board_id: ctx.cfg.nextcloud.board_id.into(), board_id: board_id.into(),
stack_id: stack_id.into(), stack_id: stack_id.into(),
card_id: card_id.into(), card_id: card_id.into(),
label_id: label_id.into(), label_id: label_id.into(),
@ -77,6 +85,7 @@ async fn dump(
#[test_log::test(tokio::test)] #[test_log::test(tokio::test)]
async fn no_dump( async fn no_dump(
ctx: FullCtx, ctx: FullCtx,
board_id: NextcloudBoardId,
stack_id: NextcloudStackId, stack_id: NextcloudStackId,
card_id: NextcloudCardId, card_id: NextcloudCardId,
label_id: NextcloudLabelId, label_id: NextcloudLabelId,
@ -88,7 +97,7 @@ async fn no_dump(
//when //when
Command::Nextcloud(NextcloudCommand::Card(NextcloudCardCommand::AddLabel { Command::Nextcloud(NextcloudCommand::Card(NextcloudCardCommand::AddLabel {
dump: false, dump: false,
board_id: ctx.cfg.nextcloud.board_id.into(), board_id: board_id.into(),
stack_id: stack_id.into(), stack_id: stack_id.into(),
card_id: card_id.into(), card_id: card_id.into(),
label_id: label_id.into(), label_id: label_id.into(),

View file

@ -1,6 +1,11 @@
// //
use super::*; use super::*;
#[rstest::fixture]
fn board_id() -> NextcloudBoardId {
NextcloudBoardId::new(2)
}
#[rstest::fixture] #[rstest::fixture]
fn stack_id() -> NextcloudStackId { fn stack_id() -> NextcloudStackId {
NextcloudStackId::new(1) NextcloudStackId::new(1)
@ -10,14 +15,15 @@ fn stack_id() -> NextcloudStackId {
fn ctx() -> FullCtx { fn ctx() -> FullCtx {
let fs = given::a_filesystem(); let fs = given::a_filesystem();
let nextcloud_config = given::a_nextcloud_config(); let nextcloud_config = given::a_nextcloud_config();
let hostname = &nextcloud_config.hostname;
let board_id = board_id();
let stack_id = stack_id();
let mock_net = given::a_network(); let mock_net = given::a_network();
mock_net mock_net
.on() .on()
.post(crate::f!( .post(crate::f!(
"{}/index.php/apps/deck/api/v1.0/boards/{}/stacks/1/cards", "{hostname}/index.php/apps/deck/api/v1.0/boards/{board_id}/stacks/{stack_id}/cards",
nextcloud_config.hostname,
nextcloud_config.board_id
)) ))
.respond(StatusCode::OK) .respond(StatusCode::OK)
.body(include_str!( .body(include_str!(
@ -40,7 +46,12 @@ fn ctx() -> FullCtx {
#[case::no_desc(None)] #[case::no_desc(None)]
#[case::desc(Some(s!("my new description")))] #[case::desc(Some(s!("my new description")))]
#[test_log::test(tokio::test)] #[test_log::test(tokio::test)]
async fn dump(ctx: FullCtx, stack_id: NextcloudStackId, #[case] description: Option<String>) { async fn dump(
ctx: FullCtx,
board_id: NextcloudBoardId,
stack_id: NextcloudStackId,
#[case] description: Option<String>,
) {
//given //given
let prt = ctx.prt.clone(); let prt = ctx.prt.clone();
let prt = prt.as_test().unwrap(); let prt = prt.as_test().unwrap();
@ -48,7 +59,7 @@ async fn dump(ctx: FullCtx, stack_id: NextcloudStackId, #[case] description: Opt
//when //when
Command::Nextcloud(NextcloudCommand::Card(NextcloudCardCommand::Create { Command::Nextcloud(NextcloudCommand::Card(NextcloudCardCommand::Create {
dump: true, dump: true,
board_id: ctx.cfg.nextcloud.board_id.into(), board_id: board_id.into(),
stack_id: stack_id.into(), stack_id: stack_id.into(),
title: "my new card".to_string(), title: "my new card".to_string(),
description, description,
@ -69,7 +80,12 @@ async fn dump(ctx: FullCtx, stack_id: NextcloudStackId, #[case] description: Opt
#[case::no_desc(None)] #[case::no_desc(None)]
#[case::desc(Some(s!("my new description")))] #[case::desc(Some(s!("my new description")))]
#[test_log::test(tokio::test)] #[test_log::test(tokio::test)]
async fn no_dump(ctx: FullCtx, stack_id: NextcloudStackId, #[case] description: Option<String>) { async fn no_dump(
ctx: FullCtx,
board_id: NextcloudBoardId,
stack_id: NextcloudStackId,
#[case] description: Option<String>,
) {
//given //given
let prt = ctx.prt.clone(); let prt = ctx.prt.clone();
let prt = prt.as_test().unwrap(); let prt = prt.as_test().unwrap();
@ -77,7 +93,7 @@ async fn no_dump(ctx: FullCtx, stack_id: NextcloudStackId, #[case] description:
//when //when
Command::Nextcloud(NextcloudCommand::Card(NextcloudCardCommand::Create { Command::Nextcloud(NextcloudCommand::Card(NextcloudCardCommand::Create {
dump: false, dump: false,
board_id: ctx.cfg.nextcloud.board_id.into(), board_id: board_id.into(),
stack_id: stack_id.into(), stack_id: stack_id.into(),
title: "my new card".to_string(), title: "my new card".to_string(),
description, description,

View file

@ -1,6 +1,11 @@
// //
use super::*; use super::*;
#[rstest::fixture]
fn board_id() -> NextcloudBoardId {
NextcloudBoardId::new(2)
}
#[rstest::fixture] #[rstest::fixture]
fn stack_id() -> NextcloudStackId { fn stack_id() -> NextcloudStackId {
NextcloudStackId::new(1) NextcloudStackId::new(1)
@ -15,14 +20,15 @@ fn card_id() -> NextcloudCardId {
fn ctx() -> FullCtx { fn ctx() -> FullCtx {
let fs = given::a_filesystem(); let fs = given::a_filesystem();
let nextcloud_config = given::a_nextcloud_config(); let nextcloud_config = given::a_nextcloud_config();
let hostname = &nextcloud_config.hostname;
let board_id = board_id();
let stack_id = stack_id();
let mock_net = given::a_network(); let mock_net = given::a_network();
mock_net mock_net
.on() .on()
.get(crate::f!( .get(crate::f!(
"{}/index.php/apps/deck/api/v1.0/boards/{}/stacks/1/cards/321", "{hostname}/index.php/apps/deck/api/v1.0/boards/{board_id}/stacks/{stack_id}/cards/321",
nextcloud_config.hostname,
nextcloud_config.board_id
)) ))
.respond(StatusCode::OK) .respond(StatusCode::OK)
.body(include_str!( .body(include_str!(
@ -43,7 +49,12 @@ fn ctx() -> FullCtx {
#[rstest::rstest] #[rstest::rstest]
#[test_log::test(tokio::test)] #[test_log::test(tokio::test)]
async fn dump(ctx: FullCtx, stack_id: NextcloudStackId, card_id: NextcloudCardId) { async fn dump(
ctx: FullCtx,
board_id: NextcloudBoardId,
stack_id: NextcloudStackId,
card_id: NextcloudCardId,
) {
//given //given
let prt = ctx.prt.clone(); let prt = ctx.prt.clone();
let prt = prt.as_test().unwrap(); let prt = prt.as_test().unwrap();
@ -51,7 +62,7 @@ async fn dump(ctx: FullCtx, stack_id: NextcloudStackId, card_id: NextcloudCardId
//when //when
Command::Nextcloud(NextcloudCommand::Card(NextcloudCardCommand::Get { Command::Nextcloud(NextcloudCommand::Card(NextcloudCardCommand::Get {
dump: true, dump: true,
board_id: ctx.cfg.nextcloud.board_id.into(), board_id: board_id.into(),
stack_id: stack_id.into(), stack_id: stack_id.into(),
card_id: card_id.into(), card_id: card_id.into(),
})) }))
@ -69,7 +80,12 @@ async fn dump(ctx: FullCtx, stack_id: NextcloudStackId, card_id: NextcloudCardId
#[rstest::rstest] #[rstest::rstest]
#[test_log::test(tokio::test)] #[test_log::test(tokio::test)]
async fn no_dump(ctx: FullCtx, stack_id: NextcloudStackId, card_id: NextcloudCardId) { async fn no_dump(
ctx: FullCtx,
board_id: NextcloudBoardId,
stack_id: NextcloudStackId,
card_id: NextcloudCardId,
) {
//given //given
let prt = ctx.prt.clone(); let prt = ctx.prt.clone();
let prt = prt.as_test().unwrap(); let prt = prt.as_test().unwrap();
@ -77,7 +93,7 @@ async fn no_dump(ctx: FullCtx, stack_id: NextcloudStackId, card_id: NextcloudCar
//when //when
Command::Nextcloud(NextcloudCommand::Card(NextcloudCardCommand::Get { Command::Nextcloud(NextcloudCommand::Card(NextcloudCardCommand::Get {
dump: false, dump: false,
board_id: ctx.cfg.nextcloud.board_id.into(), board_id: board_id.into(),
stack_id: stack_id.into(), stack_id: stack_id.into(),
card_id: card_id.into(), card_id: card_id.into(),
})) }))

View file

@ -7,8 +7,13 @@ use crate::Command;
use super::*; use super::*;
#[rstest::fixture] #[rstest::fixture]
fn stack_id() -> i64 { fn board_id() -> NextcloudBoardId {
318 NextcloudBoardId::new(1)
}
#[rstest::fixture]
fn stack_id() -> NextcloudStackId {
NextcloudStackId::new(318)
} }
#[rstest::fixture] #[rstest::fixture]
@ -17,7 +22,7 @@ fn ctx() -> FullCtx {
let nextcloud_config = given::a_nextcloud_config(); let nextcloud_config = given::a_nextcloud_config();
let hostname = nextcloud_config.hostname; let hostname = nextcloud_config.hostname;
let board_id = nextcloud_config.board_id; let board_id = board_id();
let stack_id = stack_id(); let stack_id = stack_id();
let mock_net = given::a_network(); let mock_net = given::a_network();
@ -37,7 +42,7 @@ fn ctx() -> FullCtx {
#[rstest::rstest] #[rstest::rstest]
#[test_log::test(tokio::test)] #[test_log::test(tokio::test)]
async fn dump(ctx: FullCtx) { async fn dump(ctx: FullCtx, board_id: NextcloudBoardId, stack_id: NextcloudStackId) {
//given //given
let prt = ctx.prt.clone(); let prt = ctx.prt.clone();
let prt = prt.as_test().unwrap(); let prt = prt.as_test().unwrap();
@ -45,8 +50,8 @@ async fn dump(ctx: FullCtx) {
//when //when
Command::Nextcloud(NextcloudCommand::Stack(NextcloudStackCommand::Get { Command::Nextcloud(NextcloudCommand::Stack(NextcloudStackCommand::Get {
dump: true, dump: true,
board_id: ctx.cfg.nextcloud.board_id.into(), board_id: board_id.into(),
stack_id: stack_id(), stack_id: stack_id.into(),
})) }))
.execute(&ctx) .execute(&ctx)
.await .await
@ -62,7 +67,7 @@ async fn dump(ctx: FullCtx) {
#[rstest::rstest] #[rstest::rstest]
#[test_log::test(tokio::test)] #[test_log::test(tokio::test)]
async fn no_dump(ctx: FullCtx) { async fn no_dump(ctx: FullCtx, board_id: NextcloudBoardId, stack_id: NextcloudStackId) {
//given //given
let prt = ctx.prt.clone(); let prt = ctx.prt.clone();
let prt = prt.as_test().unwrap(); let prt = prt.as_test().unwrap();
@ -70,8 +75,8 @@ async fn no_dump(ctx: FullCtx) {
//when //when
Command::Nextcloud(NextcloudCommand::Stack(NextcloudStackCommand::Get { Command::Nextcloud(NextcloudCommand::Stack(NextcloudStackCommand::Get {
dump: false, dump: false,
board_id: ctx.cfg.nextcloud.board_id.into(), board_id: board_id.into(),
stack_id: stack_id(), stack_id: stack_id.into(),
})) }))
.execute(&ctx) .execute(&ctx)
.await .await

View file

@ -49,12 +49,10 @@ async fn test_full_ctx_clients() -> Result<()> {
"[trello]", "[trello]",
"api_key = 'foo'", "api_key = 'foo'",
"api_secret = 'bar'", "api_secret = 'bar'",
"board_name = 'target'",
"[nextcloud]", "[nextcloud]",
"hostname = 'http://localhost:8000'", "hostname = 'http://localhost:8000'",
"username = 'bob'", "username = 'bob'",
"password = '1 <3 alice!'", "password = '1 <3 alice!'",
"board_id = 23",
] ]
.join("\n"), .join("\n"),
)?; )?;
@ -77,13 +75,11 @@ async fn test_full_ctx_clients() -> Result<()> {
trello: TrelloConfig { trello: TrelloConfig {
api_key: s!("foo").into(), api_key: s!("foo").into(),
api_secret: s!("bar").into(), api_secret: s!("bar").into(),
board_name: s!("target").into(),
}, },
nextcloud: NextcloudConfig { nextcloud: NextcloudConfig {
hostname: s!("http://localhost:8000").into(), hostname: s!("http://localhost:8000").into(),
username: s!("bob").into(), username: s!("bob").into(),
password: s!("1 <3 alice!").into(), password: s!("1 <3 alice!").into(),
board_id: 23.into(),
} }
} }
); );
@ -91,7 +87,7 @@ async fn test_full_ctx_clients() -> Result<()> {
Ok(()) Ok(())
} }
#[tokio::test] #[test_log::test(tokio::test)]
async fn test_run() -> Result<()> { async fn test_run() -> Result<()> {
//given //given
let fs = kxio::fs::temp()?; let fs = kxio::fs::temp()?;
@ -103,12 +99,10 @@ async fn test_run() -> Result<()> {
"[trello]", "[trello]",
"api_key = 'foo'", "api_key = 'foo'",
"api_secret = 'bar'", "api_secret = 'bar'",
"board_name = 'DevProjects'",
"[nextcloud]", "[nextcloud]",
"hostname = 'http://localhost:8000'", "hostname = 'http://localhost:8000'",
"username = 'bob'", "username = 'bob'",
"password = '1 <3 alice!'", "password = '1 <3 alice!'",
"board_id = 1",
] ]
.join("\n"), .join("\n"),
)?; )?;
@ -126,12 +120,6 @@ async fn test_run() -> Result<()> {
.respond(StatusCode::OK) .respond(StatusCode::OK)
.body(include_bytes!("responses/nextcloud-deck-get.json").as_slice()) .body(include_bytes!("responses/nextcloud-deck-get.json").as_slice())
.expect("nextcloud deck get"); .expect("nextcloud deck get");
mock_net
.on()
.get("http://localhost:8000/index.php/apps/deck/api/v1.0/boards/1/stacks")
.respond(StatusCode::OK)
.body(include_bytes!("responses/nextcloud-board-get.json").as_slice())
.expect("nextcloud board get");
let ctx = Ctx { let ctx = Ctx {
fs: fs.as_real(), fs: fs.as_real(),
@ -156,24 +144,18 @@ async fn test_run() -> Result<()> {
output.trim(), output.trim(),
[ [
">> Testing Trello details...", ">> Testing Trello details...",
"<<< Trello Credentials: OKAY", "<<< Trello Boards",
">> Trello Board: DevProjects", "<<<< Board: 0 Business: Cossmass Infinities",
"<<< Trello Board: OKAY", "<<<< Board: 3 Editing: Cossmass Infinities",
"<<<< List: BRAINSTORM 🤔", "<<<< Board: 4 Published: Cossmass Infinities",
"<<<< List: TODO 📚", "<<<< Board: Daily Notes 2022",
"<<<< List: DOING ⚙️", "<<<< Board: DevProjects",
"<<<< List: DONE! 🙌🏽", "<<<< Board: Fulfilment: Cossmass Infinities",
"<<<< List: Icebox ❄️",
">> Testing Nextcloud details...", ">> Testing Nextcloud details...",
"<<< Nextcloud Boards", "<<< Nextcloud Boards",
"<<<< Board: Personal Board", "<<<< Board: Personal Board",
"<<<< Board: 4 Published: Cossmass Infinities", "<<<< Board: 4 Published: Cossmass Infinities",
"<<<< Board: Fulfilment: Cossmass Infinities", "<<<< Board: Fulfilment: Cossmass Infinities",
"<<< Nextcloud Credentials: OKAY",
"<<< Nextcloud Board: Personal Board",
"<<<< Stack: Done",
"<<<< Stack: Doing",
"<<<< Stack: To do",
] ]
.join("\n") .join("\n")
); );

View file

@ -11,13 +11,10 @@ fn load_config() {
"[trello]", "[trello]",
"api_key = \"trello-api-key\"", "api_key = \"trello-api-key\"",
"api_secret = \"trello-api-secret\"", "api_secret = \"trello-api-secret\"",
"board_name = \"trello-board-name\"",
"",
"[nextcloud]", "[nextcloud]",
"hostname = \"nextcloud-hostname\"", "hostname = \"nextcloud-hostname\"",
"username = \"nextcloud-username\"", "username = \"nextcloud-username\"",
"password = \"nextcloud-password\"", "password = \"nextcloud-password\"",
"board_id = 22",
] ]
.join("\n"), .join("\n"),
) )
@ -34,13 +31,11 @@ fn load_config() {
trello: TrelloConfig { trello: TrelloConfig {
api_key: s!("trello-api-key").into(), api_key: s!("trello-api-key").into(),
api_secret: s!("trello-api-secret").into(), api_secret: s!("trello-api-secret").into(),
board_name: s!("trello-board-name").into(),
}, },
nextcloud: NextcloudConfig { nextcloud: NextcloudConfig {
hostname: s!("nextcloud-hostname").into(), hostname: s!("nextcloud-hostname").into(),
username: s!("nextcloud-username").into(), username: s!("nextcloud-username").into(),
password: s!("nextcloud-password").into(), password: s!("nextcloud-password").into(),
board_id: 22.into()
} }
} }
); );

View file

@ -30,7 +30,6 @@ pub(crate) fn a_trello_config() -> TrelloConfig {
TrelloConfig { TrelloConfig {
api_key: s!("trello-api-key").into(), api_key: s!("trello-api-key").into(),
api_secret: s!("trello-api-secret").into(), api_secret: s!("trello-api-secret").into(),
board_name: s!("trello-board-name").into(),
} }
} }
@ -38,12 +37,10 @@ pub(crate) fn a_nextcloud_config() -> NextcloudConfig {
let hostname = s!("https://host-name").into(); let hostname = s!("https://host-name").into();
let username = s!("username").into(); let username = s!("username").into();
let password = s!("password").into(); let password = s!("password").into();
let board_id = 2.into();
NextcloudConfig { NextcloudConfig {
hostname, hostname,
username, username,
password, password,
board_id,
} }
} }

View file

@ -8,10 +8,7 @@ use crate::{
board::TrelloBoardCommand, board::TrelloBoardCommand,
card::TrelloCardCommand, card::TrelloCardCommand,
member::TrelloMemberCommand, member::TrelloMemberCommand,
model::{ model::auth::{TrelloApiKey, TrelloApiSecret},
auth::{TrelloApiKey, TrelloApiSecret},
TrelloBoardName,
},
stack::TrelloStackCommand, stack::TrelloStackCommand,
}, },
FullCtx, FullCtx,
@ -62,5 +59,4 @@ impl Execute for TrelloCommand {
pub struct TrelloConfig { pub struct TrelloConfig {
pub(crate) api_key: TrelloApiKey, pub(crate) api_key: TrelloApiKey,
pub(crate) api_secret: TrelloApiSecret, pub(crate) api_secret: TrelloApiSecret,
pub(crate) board_name: TrelloBoardName,
} }