pub struct Fake {
pub orders: Arc<Mutex<Vec<String>>>,
pub next_quotes: Arc<Mutex<Vec<String>>>,
/* private fields */
}Expand description
The fake backend; its orders are counted (the tests check that an order went through once, or never).
Fields§
§orders: Arc<Mutex<Vec<String>>>The quote ids of the orders placed, in order.
next_quotes: Arc<Mutex<Vec<String>>>Quote ids of the next quotes, instead of the cart’s hash (a test’s price change).
Implementations§
Source§impl Fake
impl Fake
Sourcepub fn session(account: &str) -> Value
pub fn session(account: &str) -> Value
A connected fake session of account (what a fake login yields), its
SSO good for 60 days.
Examples found in repository?
examples/fake_order.rs (line 15)
13async fn main() -> GrabResult<()> {
14 let backend = Fake::default();
15 let slot = Arc::new(MemorySlot::new("acct-1", Some(Fake::session("Sample"))));
16 let client = backend.client(slot);
17
18 let found = client.search("ramen", 5).await?;
19 println!("{}\n", text::merchants(&found));
20
21 let menu = client.menu("fake-ramen").await?;
22 println!("{}\n", text::menu(&menu, None));
23
24 let cart = client
25 .cart(&CartOp::Add {
26 merchant_id: menu.merchant.id.clone(),
27 item_id: menu.items[0].id.clone(),
28 quantity: 2,
29 note: Some("less salt".into()),
30 })
31 .await?;
32 println!("{}\n", text::cart(&cart));
33
34 let quote = client.quote().await?;
35 println!("{}\n", text::quote("e));
36
37 // Only once the person agreed to this quote id; never retried.
38 let placed = client.place_order("e.quote_id).await?;
39 println!("placed {}\n", placed.order_id);
40 println!("{}", text::tracked(&client.track(None).await?));
41 Ok(())
42}Trait Implementations§
Source§impl GrabBackend for Fake
impl GrabBackend for Fake
Source§fn client(&self, session: Arc<dyn SessionSlot>) -> Arc<dyn GrabClient> ⓘ
fn client(&self, session: Arc<dyn SessionSlot>) -> Arc<dyn GrabClient> ⓘ
The client of the account behind
session.Auto Trait Implementations§
impl Forget for Fake
impl Freeze for Fake
impl RefUnwindSafe for Fake
impl Send for Fake
impl Sync for Fake
impl Unpin for Fake
impl UnsafeUnpin for Fake
impl UnwindSafe for Fake
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more