Moved upload_photo to an example

master
Aaron Power 7 years ago
parent 523d83022e
commit 53f403d99d
  1. 1
      Cargo.toml
  2. 12
      examples/upload_photo.rs
  3. BIN
      tests/test.png
  4. 32
      tests/upload_photo.rs

@ -22,5 +22,4 @@ version = "0.4"
features = ["serde"]
[dev-dependencies]
dotenv = "0.11"
toml = "0.4"

@ -0,0 +1,12 @@
mod register;
use std::error;
fn main() -> Result<(), Box<error::Error>> {
let mastodon = register::get_mastodon_data()?;
let input = register::read_line("Enter the path to the photo you'd like to post: ")?;
mastodon.media(input.into())?;
Ok(())
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

@ -1,32 +0,0 @@
extern crate mammut;
extern crate dotenv;
use std::env;
use mammut::{Data, Mastodon};
use dotenv::dotenv;
// Do not run this test by default because it requires a real Mastodon
// connection setup.
#[test]
#[ignore]
fn upload_photo() {
dotenv().ok();
run().unwrap();
}
fn run() -> mammut::Result<()> {
let data = Data {
base: env::var("BASE").unwrap().into(),
client_id: env::var("CLIENT_ID").unwrap().into(),
client_secret: env::var("CLIENT_SECRET").unwrap().into(),
redirect: env::var("REDIRECT").unwrap().into(),
token: env::var("TOKEN").unwrap().into(),
};
let mastodon = Mastodon::from_data(data);
mastodon.media("tests/test.png".into())?;
Ok(())
}
Loading…
Cancel
Save