46 lines
1.2 KiB
Rust
46 lines
1.2 KiB
Rust
use blog::Post;
|
|
|
|
fn main() {
|
|
let mut post = Post::new();
|
|
|
|
post.add_text("I ate a salad for lunch today");
|
|
|
|
let post = post.request_review();
|
|
|
|
let post = if let blog::PendingOrPost::PendingReviewPost(c) = post.approve() {
|
|
c
|
|
} else {
|
|
panic!("Didn't get PendingReviewPost after first call to approve");
|
|
};
|
|
let mut post = post.reject();
|
|
post.add_text(" and it was good!");
|
|
|
|
let post = post.request_review();
|
|
let post = if let blog::PendingOrPost::PendingReviewPost(c) = post.approve() {
|
|
c
|
|
} else {
|
|
panic!("Didn't get PendingReviewPost after first call to approve");
|
|
};
|
|
let post = if let blog::PendingOrPost::Post(c) = post.approve() {
|
|
c
|
|
} else {
|
|
panic!("Didn't get Post after first call to approve");
|
|
};
|
|
|
|
assert_eq!("I ate a salad for lunch today and it was good!", post.content());
|
|
}
|
|
|
|
// use blog::Post;
|
|
|
|
// fn main() {
|
|
// let mut post = Post::new();
|
|
|
|
// post.add_text("I ate a salad for lunch today");
|
|
// assert_eq!("", post.content());
|
|
|
|
// post.request_review();
|
|
// assert_eq!("", post.content());
|
|
|
|
// post.approve();
|
|
// assert_eq!("I ate a salad for lunch today", post.content());
|
|
// }
|