Skip to content

Commit

Permalink
Test project empty
Browse files Browse the repository at this point in the history
  • Loading branch information
alanvardy committed May 31, 2023
1 parent 38d79e8 commit a52903b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ coverage:
base: auto
patch:
default:
target: 40%
target: 80%
threshold: 2%
base: auto
33 changes: 33 additions & 0 deletions src/projects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,4 +612,37 @@ mod tests {
let expected: Vec<String> = vec![String::from("NEWPROJECT")];
assert_eq!(result, expected);
}

#[test]
fn can_empty() {
let mut server = mockito::Server::new();
let mock = server
.mock("POST", "/sync/v9/projects/get_data")
.with_status(200)
.with_header("content-type", "application/json")
.with_body(test::responses::items())
.create();

let mock2 = server
.mock("POST", "/sync/v9/sync")
.with_status(200)
.with_header("content-type", "application/json")
.with_body(test::responses::sync())
.create();

let mut config =
test::fixtures::config(Some(server.url()), Some(String::from("NEWTEXT")), Some(0));

config.add_project(String::from("projectname"), 123);

let result = empty(&config, "projectname");
let string = if test::helpers::supports_coloured_output() {
"\u{1b}[32mSuccessfully emptied projectname\u{1b}[0m"
} else {
"Successfully emptied projectname"
};
assert_eq!(result, Ok(String::from(string)));
mock.assert();
mock2.assert();
}
}

0 comments on commit a52903b

Please sign in to comment.