Second series of tests

This commit is contained in:
VC
2020-02-29 15:39:27 +01:00
parent c38b46cb8d
commit 52f98690a5
3 changed files with 119 additions and 18 deletions

60
Cargo.lock generated
View File

@@ -128,6 +128,12 @@ dependencies = [
"iovec", "iovec",
] ]
[[package]]
name = "bytes"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "130aac562c0dd69c56b3b1cc8ffd2e17be31d0b6c25b61c96b76231aa23e39e1"
[[package]] [[package]]
name = "c2-chacha" name = "c2-chacha"
version = "0.2.3" version = "0.2.3"
@@ -337,7 +343,7 @@ dependencies = [
"serde_derive", "serde_derive",
"serde_json", "serde_json",
"sha-1", "sha-1",
"tokio", "tokio 0.1.22",
"url 1.7.2", "url 1.7.2",
] ]
@@ -491,7 +497,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462" checksum = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462"
dependencies = [ dependencies = [
"byteorder", "byteorder",
"bytes", "bytes 0.4.12",
"fnv", "fnv",
"futures", "futures",
"http", "http",
@@ -527,7 +533,7 @@ version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6ccf5ede3a895d8856620237b2f02972c1bbc78d2965ad7fe8838d4a0ed41f0" checksum = "d6ccf5ede3a895d8856620237b2f02972c1bbc78d2965ad7fe8838d4a0ed41f0"
dependencies = [ dependencies = [
"bytes", "bytes 0.4.12",
"fnv", "fnv",
"itoa", "itoa",
] ]
@@ -538,7 +544,7 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" checksum = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d"
dependencies = [ dependencies = [
"bytes", "bytes 0.4.12",
"futures", "futures",
"http", "http",
"tokio-buf", "tokio-buf",
@@ -556,7 +562,7 @@ version = "0.12.35"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9dbe6ed1438e1f8ad955a4701e9a944938e9519f6888d12d8558b645e247d5f6" checksum = "9dbe6ed1438e1f8ad955a4701e9a944938e9519f6888d12d8558b645e247d5f6"
dependencies = [ dependencies = [
"bytes", "bytes 0.4.12",
"futures", "futures",
"futures-cpupool", "futures-cpupool",
"h2", "h2",
@@ -569,7 +575,7 @@ dependencies = [
"net2", "net2",
"rustc_version", "rustc_version",
"time", "time",
"tokio", "tokio 0.1.22",
"tokio-buf", "tokio-buf",
"tokio-executor", "tokio-executor",
"tokio-io", "tokio-io",
@@ -586,7 +592,7 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a800d6aa50af4b5850b2b0f659625ce9504df908e9733b635720483be26174f" checksum = "3a800d6aa50af4b5850b2b0f659625ce9504df908e9733b635720483be26174f"
dependencies = [ dependencies = [
"bytes", "bytes 0.4.12",
"futures", "futures",
"hyper", "hyper",
"native-tls", "native-tls",
@@ -600,7 +606,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad5125567a8328ced412a29a52a3ca0a2520c617d40a8bee62d12d877eec236c" checksum = "ad5125567a8328ced412a29a52a3ca0a2520c617d40a8bee62d12d877eec236c"
dependencies = [ dependencies = [
"base64", "base64",
"bytes", "bytes 0.4.12",
"cfg-if", "cfg-if",
"http", "http",
"httparse", "httparse",
@@ -950,6 +956,12 @@ version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
[[package]]
name = "pin-project-lite"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "237844750cfbb86f67afe27eee600dfbbcb6188d734139b534cbfbf4f96792ae"
[[package]] [[package]]
name = "pkg-config" name = "pkg-config"
version = "0.3.17" version = "0.3.17"
@@ -1189,7 +1201,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f88643aea3c1343c804950d7bf983bd2067f5ab59db6d613a08e05572f2714ab" checksum = "f88643aea3c1343c804950d7bf983bd2067f5ab59db6d613a08e05572f2714ab"
dependencies = [ dependencies = [
"base64", "base64",
"bytes", "bytes 0.4.12",
"cookie", "cookie",
"cookie_store", "cookie_store",
"encoding_rs", "encoding_rs",
@@ -1206,7 +1218,7 @@ dependencies = [
"serde_json", "serde_json",
"serde_urlencoded", "serde_urlencoded",
"time", "time",
"tokio", "tokio 0.1.22",
"tokio-executor", "tokio-executor",
"tokio-io", "tokio-io",
"tokio-threadpool", "tokio-threadpool",
@@ -1254,6 +1266,8 @@ dependencies = [
"clap", "clap",
"egg-mode", "egg-mode",
"mammut", "mammut",
"serde",
"tokio 0.2.13",
"toml", "toml",
] ]
@@ -1381,7 +1395,7 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d" checksum = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d"
dependencies = [ dependencies = [
"bytes", "bytes 0.4.12",
] ]
[[package]] [[package]]
@@ -1468,7 +1482,7 @@ version = "0.1.22"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" checksum = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6"
dependencies = [ dependencies = [
"bytes", "bytes 0.4.12",
"futures", "futures",
"mio", "mio",
"num_cpus", "num_cpus",
@@ -1486,13 +1500,23 @@ dependencies = [
"tokio-uds", "tokio-uds",
] ]
[[package]]
name = "tokio"
version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fa5e81d6bc4e67fe889d5783bd2a128ab2e0cfa487e0be16b6a8d177b101616"
dependencies = [
"bytes 0.5.4",
"pin-project-lite",
]
[[package]] [[package]]
name = "tokio-buf" name = "tokio-buf"
version = "0.1.1" version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46" checksum = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46"
dependencies = [ dependencies = [
"bytes", "bytes 0.4.12",
"either", "either",
"futures", "futures",
] ]
@@ -1503,7 +1527,7 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25b2998660ba0e70d18684de5d06b70b70a3a747469af9dea7618cc59e75976b" checksum = "25b2998660ba0e70d18684de5d06b70b70a3a747469af9dea7618cc59e75976b"
dependencies = [ dependencies = [
"bytes", "bytes 0.4.12",
"futures", "futures",
"tokio-io", "tokio-io",
] ]
@@ -1545,7 +1569,7 @@ version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674"
dependencies = [ dependencies = [
"bytes", "bytes 0.4.12",
"futures", "futures",
"log", "log",
] ]
@@ -1585,7 +1609,7 @@ version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "98df18ed66e3b72e742f185882a9e201892407957e45fbff8da17ae7a7c51f72" checksum = "98df18ed66e3b72e742f185882a9e201892407957e45fbff8da17ae7a7c51f72"
dependencies = [ dependencies = [
"bytes", "bytes 0.4.12",
"futures", "futures",
"iovec", "iovec",
"mio", "mio",
@@ -1628,7 +1652,7 @@ version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2a0b10e610b39c38b031a2fcab08e4b82f16ece36504988dcbd81dbba650d82" checksum = "e2a0b10e610b39c38b031a2fcab08e4b82f16ece36504988dcbd81dbba650d82"
dependencies = [ dependencies = [
"bytes", "bytes 0.4.12",
"futures", "futures",
"log", "log",
"mio", "mio",
@@ -1643,7 +1667,7 @@ version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5076db410d6fdc6523df7595447629099a1fdc47b3d9f896220780fa48faf798" checksum = "5076db410d6fdc6523df7595447629099a1fdc47b3d9f896220780fa48faf798"
dependencies = [ dependencies = [
"bytes", "bytes 0.4.12",
"futures", "futures",
"iovec", "iovec",
"libc", "libc",

View File

@@ -7,7 +7,9 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
serde = { version = "1.0", features = ["derive"] }
toml = "^0.5" toml = "^0.5"
clap = "^2.33" clap = "^2.33"
tokio = "^0.2"
egg-mode = "^0.13" egg-mode = "^0.13"
mammut = "^0.13" mammut = "^0.13"

View File

@@ -1,4 +1,79 @@
// std
use std::fs::read_to_string;
// clap // clap
use clap::{App, Arg}; use clap::{App, Arg};
// toml
use serde::Deserialize;
// egg-mode
use egg_mode::{
Token,
KeyPair,
tweet::{
user_timeline,
Tweet,
},
};
// tokio
use tokio::runtime::current_thread::block_on_all;
#[derive(Debug, Deserialize)]
pub struct Config {
twitter: TwitterConfig,
}
#[derive(Debug, Deserialize)]
struct TwitterConfig {
username: String,
consumer_key: String,
consumer_secret: String,
access_key: String,
access_secret: String,
}
impl Config {
pub fn new() -> Config {
let matches = App::new(env!("CARGO_PKG_NAME"))
.version(env!("CARGO_PKG_VERSION"))
.about("A Twitter to Mastodon bot")
.arg(Arg::with_name("config")
.short("c")
.long("config")
.value_name("CONFIG_FILE")
.help("TOML config file for scootaloo (default /usr/local/etc/scootaloo.toml)")
.takes_value(true)
.display_order(1))
.get_matches();
let toml_file = matches.value_of("config").unwrap_or("/usr/local/etc/scootaloo.toml");
let toml_config = read_to_string(toml_file).unwrap_or_else(|e|
panic!("Cannot open config file {}: {}", toml_file, e)
);
let config: Config = toml::from_str(&toml_config).unwrap_or_else(|e|
panic!("Cannot parse TOML file {}: {}", toml_file, e)
);
config
}
}
pub fn run(config: Config) {
let con_token = KeyPair::new(config.twitter.consumer_key, config.twitter.consumer_secret);
let access_token = KeyPair::new(config.twitter.access_key, config.twitter.access_secret);
let token = Token::Access {
consumer: con_token,
access: access_token,
};
let timeline = user_timeline(&config.twitter.username, false, false, &token)
.with_page_size(200)
.older(None);
timeline.types();
}